package CarSystem; public class Car { String CarName; String Color; String CarNum; public Car(String carName, String color, String carNum) { CarName = carName; Color = color; CarNum = carNum; } public String getCarName() { return CarName; } public String getColor() { return Color; } public String getCarNum() { return CarNum; } public void setCarName(String carName) { CarName = carName; } public void setColor(String color) { Color = color; } public void setCarNum(String carNum) { CarNum = carNum; } @Override public String toString() { return "汽车信息{" + "汽车型号='" + CarName + '\'' + ",\n车辆颜色='" + Color + '\'' + ",\n车牌号='" + CarNum + '\'' + '}'; } }
package CarSystem;
public class Car
{
String CarName;
String Color;
String CarNum;
public Car(String carName, String color, String carNum)
{
CarName = carName;
Color = color;
CarNum = carNum;
}
public String getCarName()
{
return CarName;
}
public String getColor()
{
return Color;
}
public String getCarNum()
{
return CarNum;
}
public void setCarName(String carName)
{
CarName = carName;
}
public void setColor(String color)
{
Color = color;
}
public void setCarNum(String carNum)
{
CarNum = carNum;
}
@Override
public String toString()
{
return "汽车信息{" +
"汽车型号='" + CarName + '\'' +
",\n车辆颜色='" + Color + '\'' +
",\n车牌号='" + CarNum + '\'' +
'}';
}
}
package CarSystem; public class RentCar extends Car { private boolean State; public RentCar(String carName, String color, String carNum, boolean state) { super(carName, color, carNum); State = state; } public boolean isState() { return State; } public void setState(boolean state) { State = state; } @Override public String toString() { return "租车信息{" + super.toString() + ",\n车辆状态=" + State + '}'; } }
package CarSystem;
public class RentCar extends Car
{
private boolean State;
public RentCar(String carName, String color, String carNum, boolean state)
{
super(carName, color, carNum);
State = state;
}
public boolean isState()
{
return State;
}
public void setState(boolean state)
{
State = state;
}
@Override
public String toString() {
return "租车信息{" +
super.toString() +
",\n车辆状态=" + State +
'}';
}
}
package CarSystem; public class Tenent { String Name; long PhoneNumber; String password; double balance; public Tenent(String name, long phoneNumber, String password, double balance) { Name = name; PhoneNumber = phoneNumber; this.password = password; this.balance = balance; } public Tenent(String name) { this.Name = Name; } public String getName() { return Name; } public long getPhoneNumber() { return PhoneNumber; } public String getPassword() { return password; } public double getBalance() { return balance; } public void setName(String name) { Name = name; } public void setPhoneNumber(long phoneNumber) { PhoneNumber = phoneNumber; } public void setPassword(String password) { this.password = password; } public void setBalance(double balance) { this.balance = balance; } @Override public String toString() { return "租客信息{" + ",\n租客姓名='" + Name + '\'' + ",\n租客电话=" + PhoneNumber + ",\n密码='" + password + '\'' + ",\n余额=" + balance + '}'; } }
package CarSystem;
public class Tenent
{
String Name;
long PhoneNumber;
String password;
double balance;
public Tenent(String name, long phoneNumber, String password, double balance)
{
Name = name;
PhoneNumber = phoneNumber;
this.password = password;
this.balance = balance;
}
public Tenent(String name)
{
this.Name = Name;
}
public String getName()
{
return Name;
}
public long getPhoneNumber()
{
return PhoneNumber;
}
public String getPassword()
{
return password;
}
public double getBalance()
{
return balance;
}
public void setName(String name)
{
Name = name;
}
public void setPhoneNumber(long phoneNumber)
{
PhoneNumber = phoneNumber;
}
public void setPassword(String password)
{
this.password = password;
}
public void setBalance(double balance)
{
this.balance = balance;
}
@Override
public String toString() {
return "租客信息{" +
",\n租客姓名='" + Name + '\'' +
",\n租客电话=" + PhoneNumber +
",\n密码='" + password + '\'' +
",\n余额=" + balance +
'}';
}
}
package CarSystem; public class VIPTenent extends Tenent { private String TenentGrade; private boolean percent; private double bonusPoints; public VIPTenent(String name, long phoneNumber, String password, double balance, String tenentGrade, boolean percent, double bonusPoints) { super(name, phoneNumber, password, balance); TenentGrade = tenentGrade; this.percent = percent; this.bonusPoints = bonusPoints; } public VIPTenent(String name, String TenentGrade) { super(name); this.TenentGrade = TenentGrade; } public String getTenentGrade() { return TenentGrade; } public boolean isPercent() { return percent; } public double getBonusPoints() { return bonusPoints; } public void setTenentGrade(String tenentGrade) { TenentGrade = tenentGrade; } public void setPercent(boolean percent) { this.percent = percent; } public void setBonusPoints(int bonusPoints) { this.bonusPoints = bonusPoints; } @Override public String toString() { return "会员信息{" + super.toString() + "身份等级='" + TenentGrade + '\'' + ",\n会员折扣=" + percent + ",\n会员积分=" + bonusPoints + '}'; } }
package CarSystem;
public class VIPTenent extends Tenent
{
private String TenentGrade;
private boolean percent;
private double bonusPoints;
public VIPTenent(String name, long phoneNumber, String password, double balance, String tenentGrade, boolean percent, double bonusPoints)
{
super(name, phoneNumber, password, balance);
TenentGrade = tenentGrade;
this.percent = percent;
this.bonusPoints = bonusPoints;
}
public VIPTenent(String name, String TenentGrade) {
super(name);
this.TenentGrade = TenentGrade;
}
public String getTenentGrade()
{
return TenentGrade;
}
public boolean isPercent()
{
return percent;
}
public double getBonusPoints()
{
return bonusPoints;
}
public void setTenentGrade(String tenentGrade)
{
TenentGrade = tenentGrade;
}
public void setPercent(boolean percent)
{
this.percent = percent;
}
public void setBonusPoints(int bonusPoints)
{
this.bonusPoints = bonusPoints;
}
@Override
public String toString() {
return "会员信息{" +
super.toString() +
"身份等级='" + TenentGrade + '\'' +
",\n会员折扣=" + percent +
",\n会员积分=" + bonusPoints +
'}';
}
}
package CarSystem; import java.util.HashMap; import java.util.Map; public class RentCarManage { private int deadTime; private int rentDays; private double normalRent = 0.1; private double delayRent = 1.0; private static int CarNo; private static int TenentNum; private HashMapCar; private HashMap Tenent; public RentCarManage() { Car = new HashMap<>(); Tenent = new HashMap<>(); CarNo = 0; TenentNum = 0; } public void AddCar(String carName, String color, String carNum, boolean state) { RentCar car = new RentCar(carName,color,carNum,state); Car.put(++CarNo,car); System.out.println("添加成功"); } public void DeleteCar(int CarNo) { if(Car.containsKey(CarNo)) { Car.remove(CarNo); System.out.println("删除成功"); } else { System.out.println("查无此车"); } } public void ModifyCar(int CarNo,String carName, String color, String carNum, boolean state) { if(Car.containsKey(CarNo)) { Car.remove(CarNo); RentCar car = new RentCar(carName,color,carNum,state); Car.put(CarNo,car); System.out.println("修改成功"); } else { System.out.println("查无此车"); } } public void QueryCar(int CarNo) { if(Car.containsKey(CarNo)) { System.out.println("车辆信息如下"); System.out.println(CarNo + Car.get(CarNo).toString()); } else { System.out.println("查无此车"); } } public void AddTenent(String name, long phoneNumber, String password, double balance, String tenentGrade, boolean percent, double bonusPoints) { VIPTenent tenent = new VIPTenent(name,phoneNumber,password,balance,tenentGrade,percent,bonusPoints); Tenent.put(++TenentNum,tenent); System.out.println("添加成功"); } public void ShowAllCar() { for(Map.Entry entry: Car.entrySet()) { System.out.println("车辆编号: "+ entry.getKey()+ " 车辆信息: "+entry.getValue()); } } public void ShowAllTenent() { for(Map.Entry entry: Tenent.entrySet()) { System.out.println("客户序号: "+ entry.getKey()+ " 客户信息: "+entry.getValue()); } } }
package CarSystem;
import java.util.HashMap;
import java.util.Map;
public class RentCarManage
{
private int deadTime;
private int rentDays;
private double normalRent = 0.1;
private double delayRent = 1.0;
private static int CarNo;
private static int TenentNum;
private HashMap Car;
private HashMap Tenent;
public RentCarManage()
{
Car = new HashMap<>();
Tenent = new HashMap<>();
CarNo = 0;
TenentNum = 0;
}
public void AddCar(String carName, String color, String carNum, boolean state)
{
RentCar car = new RentCar(carName,color,carNum,state);
Car.put(++CarNo,car);
System.out.println("添加成功");
}
public void DeleteCar(int CarNo)
{
if(Car.containsKey(CarNo))
{
Car.remove(CarNo);
System.out.println("删除成功");
}
else
{
System.out.println("查无此车");
}
}
public void ModifyCar(int CarNo,String carName, String color, String carNum, boolean state)
{
if(Car.containsKey(CarNo))
{
Car.remove(CarNo);
RentCar car = new RentCar(carName,color,carNum,state);
Car.put(CarNo,car);
System.out.println("修改成功");
}
else
{
System.out.println("查无此车");
}
}
public void QueryCar(int CarNo)
{
if(Car.containsKey(CarNo))
{
System.out.println("车辆信息如下");
System.out.println(CarNo + Car.get(CarNo).toString());
}
else
{
System.out.println("查无此车");
}
}
public void AddTenent(String name, long phoneNumber, String password, double balance, String tenentGrade, boolean percent, double bonusPoints)
{
VIPTenent tenent = new VIPTenent(name,phoneNumber,password,balance,tenentGrade,percent,bonusPoints);
Tenent.put(++TenentNum,tenent);
System.out.println("添加成功");
}
public void ShowAllCar()
{
for(Map.Entry entry: Car.entrySet())
{
System.out.println("车辆编号: "+ entry.getKey()+ " 车辆信息: "+entry.getValue());
}
}
public void ShowAllTenent()
{
for(Map.Entry entry: Tenent.entrySet())
{
System.out.println("客户序号: "+ entry.getKey()+ " 客户信息: "+entry.getValue());
}
}
}
package CarSystem; public class Test { public static void main(String[] args) { RentCarManage r = new RentCarManage(); r.AddCar("奥迪","黑色","粤A88888",true); r.AddCar("比亚迪","灰色","粤A6666",true); r.AddCar("奔驰","白色","粤A99999",true); r.AddTenent("欧万杨",15919996103L,"123456",0.0,"VIP",true,0.0); r.AddTenent("刘奕辰",15914091405L,"123345",0.0,"会员",true,0.0); r.AddTenent("曹操",13712341234L,"1212635",0.0,"用户",false,0.0); r.ShowAllCar(); r.ShowAllTenent(); r.QueryCar(1); r.DeleteCar(1); } }
package CarSystem;
public class Test
{
public static void main(String[] args)
{
RentCarManage r = new RentCarManage();
r.AddCar("奥迪","黑色","粤A88888",true);
r.AddCar("比亚迪","灰色","粤A6666",true);
r.AddCar("奔驰","白色","粤A99999",true);
r.AddTenent("欧万杨",15919996103L,"123456",0.0,"VIP",true,0.0);
r.AddTenent("刘奕辰",15914091405L,"123345",0.0,"会员",true,0.0);
r.AddTenent("曹操",13712341234L,"1212635",0.0,"用户",false,0.0);
r.ShowAllCar();
r.ShowAllTenent();
r.QueryCar(1);
r.DeleteCar(1);
}
}