要求:有客车,货车,皮卡三大类的车可以出租,实现出租车的数量,价格以及货物人数的一个报备。
思路:先写个 车的抽象类然后在分别写出客车,货车,皮卡的类,再用super继承抽象类。
然后写个测试类实现租车系统的运行生成账单。
car 抽象类
package cars01;
public abstract class car {
String carName;
int persons;
double weights;
int rent;
public car(String carName,int persons,int rent)
{
this.carName=carName;
this.persons=persons;
this.rent=rent;
}
public car(String carName,double weights,int rent)
{
this.carName=carName;
this.weights=weights;
this.rent=rent;
}
public car(String carName,double weights,int persons,int rent)
{
this.carName=carName;
this.persons=persons;
this.weights=weights;
this.rent=rent;
}
abstract void show();
}
passenges类
package cars01;
public class passengesCar extends car {//乘客类