当前位置:文档之家› java汽车租赁系统

java汽车租赁系统

Probl e nnsJSJa v ad oc 曉Declaraticr
譎毛人芸竺卷龙長3
誌竜;■、黃走長迸产三尖北(丄■护爭2、*、:-
埔雜,■気帛冥號兰左吊茶■(】•耒〒2.丰壬n :2
竜誉范乔玉布:f y/nJ . n
也左电号害库乳垢
^A7693& is
1 3* 电臭习:9&0
'*2 Problems 航Javadoc 風Declaration w 已捕■止 a Te-5t ( 6 J [Jdva 逾用程序]C:\Prog 而亲篡声玄
番耳會弓[
壬融I否髭買的天J£:r
<»ASfc5*i产更亢=(1 •戸空2,芒基〕:2 #4tA«(L2E?Ji-S A^S (1. M Z・主址)m 亠韦率八.廷境吵童二玄:注
是苔壬读崔莘:匚y/n : n
巴军馨与K年名毬
€A371E9 參才
等匕岳中取#握屋亍》=S?再75W
|_jj RentCa『
jj Busjava
』Carjflva jj| Customer java
』MotoVehrtle-java
丄Te&t.java
丄T ruckjava
package Ren tCar;
private int seatCount;
quals(getBra nd())){
rent = days * 500;
}else if ("丰田".equals(getBrand())){ if ("GL8")){
rent = days * 600;
}else {
public class Bus extends MotoVehicle{
rent = days * 300;
}
}
return rent;
}
}
package RentCar;
public class Customer {
private String name;
public Customer(){
public Customer(String name){ = name; }
public String getName(){ return name;
}
public int calcTotalRent(MotoVehicle[] moto, int days){ int rent = 0 ;
for (int i = 0 ;i < ; i++){ if (moto[i]!= null ){
rent = rent + moto[i].calRent(days);
}
}
return rent;
}
}
package RentCar;
public abstract class MotoVehicle {
private String no; 车 2. 客车):"); motoType = ();
int random = ( int )()*(99999-10000)+10000);
switch (motoType){
case 1:
no ="粤A" + random; 马 2.丰田):”);
if () == 1){
brand ="宝马";
type = "320i";
}else {
brand ="丰田";
type = "RAV4";
}
海2.金龙):");
//根据选择得到汽车品牌if () ==1){
brand ="黄海”
}else {
brand ="金龙”
"请输入客车的座位数:");
seat = (); //汽车座位数
//实例化一个轿车对象,并添加到moto数组中for
(int i = 0 ; i < ;i ++){
if (moto[i] == null ){
moto[i] = new Bus( no,bra nd,seat);
//实例化一个汽车对象
break;
break;
"是否继续租车(y/n ):");
answer = ();
} while ("y" ));
"汽车牌号\t 汽车品牌");
for (int i = 0 ; i < ;i ++){
if (moto[i] != null ){
if (moto[i] instanceof
Car){
Car c = (Car)moto[i];
"\t" +());
}else {
Bus b = (Bus)moto[i];
"\t" +());
}
}}
"客户名:" +()+ ", 租赁天数:" +days+", 总费
用:days));
}
}
package RentCar;
public class Truck extends MotoVehicle {
private int weight ; // 吨位
public Truck(){
" +(moto,
public Truck(String no, String brand,
int weight){ super (no,brand);
= weight;
}
public int getWeight(){ return weight ;
}
public int calRent( int days){ int rent = 0;
rent = weight * 50 * days;
return rent;
}。

相关主题