空气净化器一天开多久:(在线等)求高手指点一个关于JAVA的问题

来源:百度文库 编辑:高校问答 时间:2019/11/12 22:50:12
代码如下:
//Note.java
package c07.music;

public class Note{
private String noteName;
private Note(String noteName){
this.noteName=noteName;
}
public String toString(){return noteName;}

public static final Note
MIDDLE_C =new Note("Middle_c"),
C_SHARP=new Note("C_Sharp"),
B_FLAT=new Note("B_Flat");
}
//编译成功

//Instrument.java
package c07.music;

public class Instrument {
public void play() {}
public void tune(Instrument i) {
//i.play(Note i);
i.play();
}
}
//编译成功
//Wind.java
package c07.music;

public class Wind extends Instrument{
public void play(Note n){
System.out.println("Wind.play()"+n);
}
}
//编译成功

package c07.music;
//Music.java
public class Music{
public static void tune(Instrument i){
i.play(Note.MIDDLE_C);
}
public static void main(String[] args){
Wind flute=new Wind();
tune(flute);
}
}
//编译信息:play() in c07.music.Instrument cannot be applied to (c07.music.Note)

i.play(Note.MIDDLE_C);
1 error

//Music.java
public class Music{
public static void tune(Wind i){
i.play(Note.MIDDLE_C);
}