Ugo Posada
Posts: 37
Nickname: binaryx
Registered: Dec, 2002
|
|
Re: WindError.java solution(s)
|
Posted: Jan 18, 2003 7:44 PM
|
|
> I understand that the following source demonstrates that > an override was intended but inadvertently an overload was > implemented. How does one fix the problem? > > //: c07:WindError.java > // Accidentally changing the interface. > > class NoteX { > public static final int > MIDDLE_C = 0, C_SHARP = 1, C_FLAT = 2; > } > > class InstrumentX { > public void play(int NoteX) { > System.out.println("InstrumentX.play()"); > } > } > > class WindX extends InstrumentX { > // OOPS! Changes the method interface: > public void play(NoteX n) { > System.out.println("WindX.play(NoteX n)"); > } > }
class WindX extends InstrumentX {
// OOPS! Changes the method interface:
public void play(int NoteX) {
System.out.println("super.play(n)");
}
}
However, I think the method parameter should be of type NoteX instead of int (In InstrumentX).
|
|