继承 :5、程序设计 类:汽车类 属性:排量(outPut),颜色(color) 行为:驾驶(drive)
来源:互联网 发布:2017java 编辑:程序博客网 时间:2024/04/28 02:30
package HomeWork;
/*5、程序设计
类:汽车类
属性:排量(outPut),颜色(color) 行为:驾驶(drive)
类:大众(DasAuto) 继承自 汽车类 属性: 型号(kind)
需求:
1. 所有的类都要写有参的构造方法
2. 实例化一个大众车的对象 cc , 在路上驾驶*/
public class Test_04 {
public static void main(String[] args) {
DasAuto cc = new DasAuto();
cc.DasAuto("45", "白色","Jeep");
cc.run();
}
}
class Car {
String outPut;
String color;
// public void Car(String outPut, String color) {
// this.outPut = outPut;
// this.color = color;
// }
public void drive() {
System.out.println("排量:" + outPut + "/颜色:" + color + "/在路上驾驶");
}
}
class DasAuto extends Car {
private String kind;
public void DasAuto(String outPut,String color,String kind) {
super.outPut= outPut;
super.color = color;
this.kind = kind;
}
public void run() {
System.out.println("型号:" + kind);
drive();
}
}
/*5、程序设计
类:汽车类
属性:排量(outPut),颜色(color) 行为:驾驶(drive)
类:大众(DasAuto) 继承自 汽车类 属性: 型号(kind)
需求:
1. 所有的类都要写有参的构造方法
2. 实例化一个大众车的对象 cc , 在路上驾驶*/
public class Test_04 {
public static void main(String[] args) {
DasAuto cc = new DasAuto();
cc.DasAuto("45", "白色","Jeep");
cc.run();
}
}
class Car {
String outPut;
String color;
// public void Car(String outPut, String color) {
// this.outPut = outPut;
// this.color = color;
// }
public void drive() {
System.out.println("排量:" + outPut + "/颜色:" + color + "/在路上驾驶");
}
}
class DasAuto extends Car {
private String kind;
public void DasAuto(String outPut,String color,String kind) {
super.outPut= outPut;
super.color = color;
this.kind = kind;
}
public void run() {
System.out.println("型号:" + kind);
drive();
}
}
阅读全文
0 0
- 继承 :5、程序设计 类:汽车类 属性:排量(outPut),颜色(color) 行为:驾驶(drive)
- C# Color类的颜色属性,随机生成颜色
- 面向对象 定义汽车类Vehicle属性(brand(品牌),color(颜色))方法run,子类卡车(Truck)属性 weight载重 方法拉货,轿车(Car) 属性pssebger载客数量
- 汽车类继承的问题
- Color类颜色对照表
- 排量
- 让自动驾驶汽车的行为更像人类,奥迪是这么做的
- 织梦模板下载:驾驶学校汽车类行业网站织梦模板
- 汽车驾驶初学要领
- 福克斯汽车驾驶入门
- 驾驶汽车经验
- 无人汽车驾驶
- CSS 规则,布局,背景颜色,Color属性
- 浏览器兼容性1—颜色(color属性)
- 小排量汽车真的能够省油?
- 汽车排量T和L有什么区别
- 汽车驾驶学习-驾驶技巧:倒车速成
- 汽车驾驶模拟器_汽车驾驶模拟器的分类
- 【数据结构】动态栈+括号匹配+逆波兰表达式(后缀表达式计算)
- 647. Palindromic Substrings
- [BZOJ3160]万径人踪灭-快速傅里叶变换-Manacher算法
- HDU 5695 Gym Class【拓扑排序+优先队列】
- Bailian4015 邮箱验证【字符串】
- 继承 :5、程序设计 类:汽车类 属性:排量(outPut),颜色(color) 行为:驾驶(drive)
- html <a> <form>明天测试
- POJ 3255 Roadblocks【次短路】
- django 验证码(django-simple-captcha)
- Superset搭建
- 卷积神经网络应用之图像分割
- 设计模式--观察者模式
- SQL基本常用数据类型
- 电路实践