zoukankan      html  css  js  c++  java
  • 弹奏乐器

    实现如下类之间的继承关系,并编写Music类来测试这些类。

     1 package aaa;
     2 
     3 class Instrument {
     4     public void play () {
     5         System.out.println("弹奏乐器:");
     6     }
     7 }
     8 
     9 class Wind extends Instrument {
    10     public void play () {
    11         System.out.println("弹奏Wind");
    12     }
    13     public void play2 (){
    14         System.out.println("调用wind的play2");
    15     }
    16 
    17 }
    18 
    19 class Brass extends Instrument {
    20     public void play () {
    21         System.out.println("弹奏Brass");
    22     }
    23     public void play2 () {
    24         System.out.println("调用brass的play2");
    25     }
    26 
    27 }
    28 
    29 
    30 
    31 public class Music {
    32     public static void tune (Instrument i) {
    33         i.play();
    34     }
    35 
    36     public static void main(String[] args) {
    37         Music mm = new Music();
    38         Instrument dd = new Instrument();
    39         Wind bb = new Wind();
    40         Brass cc = new Brass();
    41         tune (dd);
    42         tune (bb);
    43         tune (cc);
    44         
    45     }
    46 }
  • 相关阅读:
    SQL之层次查询
    GROUP函数
    SQL之统计
    正则表达式
    聚合函数,分析函数
    oracle函数
    Vue3.0优化
    浅谈FC
    短链接生成原理
    Vue路由传参
  • 原文地址:https://www.cnblogs.com/sxcxfl/p/10812197.html
Copyright © 2011-2022 走看看