java中怎么编写这个程序?
答案:2 悬赏:20 手机版
解决时间 2021-04-19 10:15
- 提问者网友:临风不自傲
- 2021-04-18 17:31
java中怎么编写这个程序?
最佳答案
- 五星知识达人网友:洎扰庸人
- 2021-04-18 17:48
一看就知道必须是三个类。
首先是作为父类的抽象类MotoVehicle:
public abstract class MotoVehicle{
String no;
String color;
String brand;
int mileage;
public MotoVehicle(String no){
this.no=no;
}
public abstract CalcRent(int days);
}其次是两个final的子类car和bus
final class Car extends MotoVehicle{
String type;
public Car(String on,String type){
super(on);
this.type=type;
}
public CalcRent(int days){};
}final class Bus extends MotoVehicle{
int seatCount;
public Bus(String on,int seatCount){
super(on);
this.seatCount=seatCount;
}
public CalcRent(int days){};
}
首先是作为父类的抽象类MotoVehicle:
public abstract class MotoVehicle{
String no;
String color;
String brand;
int mileage;
public MotoVehicle(String no){
this.no=no;
}
public abstract CalcRent(int days);
}其次是两个final的子类car和bus
final class Car extends MotoVehicle{
String type;
public Car(String on,String type){
super(on);
this.type=type;
}
public CalcRent(int days){};
}final class Bus extends MotoVehicle{
int seatCount;
public Bus(String on,int seatCount){
super(on);
this.seatCount=seatCount;
}
public CalcRent(int days){};
}
全部回答
- 1楼网友:低音帝王
- 2021-04-18 18:46
继承呢? 发现类以及告诉你要有三个类了。再仔细考虑考虑
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯