题目: 设计一个简易的租车系统,实现租车,并统计车型、载客数、载人数、租赁总价钱。详情请见imooc的《Java入门第二季》
1、程序分析
Step1:创建汽车类
Step2:创建租赁类,完成汽车租赁任务
2、界面需求分析
and:
最后将账单打印出来:
3.代码实现
Car.java(父类)
package com.Car;
public abstract class Car {
protected int price;
protected String name;
public String getName() {
return name;
}
public int getPrice() {
return price;
}
public int getPersonNum(){
return 0;
}
public int getGoodsNum(){
return 0;
}
}
PassenagerCar.java(子类,可载人)
package com.Car;
public class PassengerCar extends Car {
private int passengerNum;
public PassengerCar(int passengerNum,int price,String name) {
this.passengerNum = passengerNum;
this.name = name;
this.price = price;
}
public PassengerCar() {
this.passenger