用java写一个Car类 请完成下面的要求:
答案:4 悬赏:0 手机版
解决时间 2021-11-15 02:55
- 提问者网友:浩歌待明月
- 2021-11-14 14:28
用java写一个Car类 请完成下面的要求:
最佳答案
- 五星知识达人网友:杯酒困英雄
- 2021-11-14 15:59
自己写代码,多写对自己有好处
追问主要是写完不相信自己,总想找个答案对照一下,这是个什么心理呢
全部回答
- 1楼网友:长青诗
- 2021-11-14 18:20
20分太少了.东西太多.写着好累.
- 2楼网友:街头电车
- 2021-11-14 16:47
问题描述不清楚,Car类是什么样的?
- 3楼网友:风格不统一
- 2021-11-14 16:21
public class Car {
String color;
}public class Truck extends Car {
String owner;
String id;
public Truck(String s1, String s2, String s3) {
owner = s1;
id = s2;
color = s3;
}
public void show(){
System.out.println("车主姓名" + " " + "车牌号码" + " " + "车身颜色");
System.out.println(owner + " " + id + " " + color);
}
}public class Test {
public static void main(String[] args) {
Truck t1 = new Truck("Mark", "辽B8888", "Black");
t1.show();
}
}
String color;
}public class Truck extends Car {
String owner;
String id;
public Truck(String s1, String s2, String s3) {
owner = s1;
id = s2;
color = s3;
}
public void show(){
System.out.println("车主姓名" + " " + "车牌号码" + " " + "车身颜色");
System.out.println(owner + " " + id + " " + color);
}
}public class Test {
public static void main(String[] args) {
Truck t1 = new Truck("Mark", "辽B8888", "Black");
t1.show();
}
}
输出如下:
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯