曦~妍  

package mianxiangduixiang;

public class Wind extends Instrument {
    public void play() {
        System.out.println("弹奏Wind");
    }
    public void play2()
    {
        System.out.println("调用Wind的play2");
    }
    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        
    }

 

 1 package mianxiangduixiang;
 2 
 3 public class Brass extends Instrument {
 4 
 5     public void play()
 6     {
 7         System.out.println("弹奏brass");
 8     }
 9     public void play2()
10     {
11         System.out.println("调用Brass的play2");
12     }
13     public static void main(String[] args) {
14         // TODO 自动生成的方法存根
15 
16     }
17 
18 }

 

 1 package mianxiangduixiang;
 2 
 3 public class Music {
 4 
 5     public static void main(String[] args) {
 6         // TODO 自动生成的方法存根
 7          Instrument i=new Instrument();
 8          i.play();
 9           Wind w=new Wind();
10          Instrument.turn(i);
11          w.turn(w);
12          Brass b=new Brass();
13          b.turn(b);
14     }

 

 

 

posted on 2016-05-22 23:19  曦~妍  阅读(163)  评论(0编辑  收藏  举报