2015-11-14 16:18:05 -08:00

19 lines
379 B
Java

// polymorphism/music/Music.java
// ©2016 MindView LLC: see Copyright.txt
// Inheritance & upcasting.
package polymorphism.music;
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); // Upcasting
}
}
/* Output:
Wind.play() MIDDLE_C
*/