正在加载图片...
范例93:我的车类 import java. awt. Color; 执行结果 public class MyCar extends Sedan 我的爱车排文件数:5 我的爱车颜色 private Color color java. awt. Color[r=0, g=0, b=255 public MyCarO( 我的爱车轮胎型号: Bridge stone l85sT color= Color blue;∥设置车辆颜色 我的爱车引擎排气量:15985 轿车换文件方式:自排5文件 我的爱车换文件方式:自排5文件 public static void main( String args i 水压式煞车系统 MyCar mycar-new MyCarO mycarequipment(; mycar shaftgear O hycar brake public void equipment System. out printl(我的爱车排档数:" this. gearNum System. out printl("我的爱车颜色:" this color System out printIn("我的爱车轮胎型号:" this. tiretype); System out printIng("我的爱车引擎排气量:"+ this engine); public void shaftgear{换档-覆盖的新方法 super shaftgear System out print"我的爱车换档方式:自排" this. gearNum档")范例9_3:我的车类 import java.awt.Color; public class MyCar extends Sedan{ private Color color; public MyCar() { color=Color.blue; //设置车辆颜色 } public static void main(String args[]) { MyCar mycar=new MyCar(); mycar.equipment(); mycar.shiftgear (); mycar.brake(); } public void equipment(){ System.out.println("我的爱车排档数:"+this.gearNum); System.out.println("我的爱车颜色:"+this.color); System.out.println("我的爱车轮胎型号:"+this.tiretype); System.out.println("我的爱车引擎排气量:"+this.engine); } public void shiftgear(){//换档-覆盖的新方法 super.shiftgear(); System.out.println("我的爱车换档方式:自排"+this.gearNum+"档" );} } 执行结果: 我的爱车排文件数:5 我的爱车颜色: java.awt.Color[r=0,g=0,b=255] 我的爱车轮胎型号:BridgeStone185ST 我的爱车引擎排气量:1598.5 轿车换文件方式:自排5文件 我的爱车换文件方式:自排5文件 水压式煞车系统
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有