test9.10
来源:互联网 发布:淘宝手机十大黑店 编辑:程序博客网 时间:2024/05/14 23:19
我把原来的程序删除了一部分,使得题目的目的更加明确,删掉的有adjust()和String toString()如果自己添加进去也可,有一点是String toString()不能写到接口里面
enum Note{MIDDLE_C,C_SHARP,B_FLAT;}
interface Playable{
void play(Note n);
}
class Wind implements Playable{
public void play(Note n){System.out.println("Wind.play+ "+n);}
}
class Percussion implements Playable{
public void play(Note n){System.out.println("Percussion.play+ "+n);}
}
class Stringed implements Playable{
public void play(Note n){System.out.println("Stringed.play+ "+n);}
}
class Brass extends Wind{
public void play(Note n){System.out.println("Brass.play+ "+n);}
}
class Woodwind extends Wind{
public void play(Note n){System.out.println("Woodwind.play+ "+n);}
}
public class Music10 {
public static void tune(Playable p)
{p.play(Note.MIDDLE_C);}
public static void tuneall(Playable []p)
{for(Playable pl:p)
tune(pl);}
public static void main(String[] args) {
Playable [] orchestra={
new Wind(),
new Percussion(),
new Stringed(),
new Brass(),
new Woodwind()
};
tuneall(orchestra);
}
}
- test9.10
- 10月集训test9
- test9
- test9
- test9.1
- test9.3
- test9.4
- test9.5
- test9.7
- test9.8
- test9.9
- test9.12
- test9.13
- test9.14
- test9.15
- test9.16
- test9.17
- test9.18
- UGUI实现血条跟随
- 学习笔记 - BufferedReader包装FileReader读取文本文件
- Python函数:装饰器
- openmeetings3.0.x 源码编译+改造
- C++笔记
- test9.10
- 使用Three.js + Blender构建在浏览器端显示的3D模型(4)
- ocp-v13-067
- 微信公众平台接入经验分享,纯干货
- php 和ios存cookie的问题
- 修改字符集
- 《企业应用架构模式》阅读笔记--第二章、第三章
- Codeforces Round #322 C Developing Skills
- ocp-v13-068