- 210
- 0
- 约1.89千字
- 约 4页
- 2019-07-03 发布于浙江
- 举报
一 问题
某汽车租赁公司出租多种车辆,车型及租金情况如下:
编写程序实现计算租赁价。
二 具体实现
MotoVehicle类:
abstract class MotoVehicle {
//车牌号
String no=null;
//品牌
String brand=null;
//颜色
char color;
//里程
int mileage;
//总金额
int num;
public abstract int CalcRent(int days);
Car类:
final class Car extends MotoVehicle{
private String type;
public Car(String no,String type){
this.no=no;
this.type=type;
}
//方法重写
public int CalcRent(int days) {
return 0;
}
//方法重载
public int CalcRent(int days,String type){
//1表示别克商务舱GL8,2表示宝马550i,3表示别克林荫大道
switch(type){
case 1:
num=600*days;
break;
case
原创力文档

文档评论(0)