我对编程很陌生。这是 carHire 类。两者之一。我需要开发一个基于 GUI 的租车应用程序。所以当我输入时,似乎一切正常,但我的租金仍然是0。我想不通。
`公共类租车{
private String customerName;
private String licenseNumber;
private int daysHired;
CarHire(){
customerName=null;
licenseNumber=null;
daysHired=0;
}
CarHire(String customerName, String licenseNumber, int daysHired){
this.customerName = customerName;
this.licenseNumber = licenseNumber;
this.daysHired = daysHired;
}
public void setCustomerName(String customerName){
this.customerName = customerName;
}
public void setLicenseNumber(String licenseNumber){
this.licenseNumber = licenseNumber;
}
public void setDaysHired(int daysHired){
this.daysHired = daysHired;
}
public String getCustomerName()
{
return customerName;
}
public String getLicenseNumber()
{
return licenseNumber;
}
public int getDaysHired()
{
return daysHired;
}
public double calculateHireRental(){
final double BASE_RATE = 34.5;
final double NEXT_TIER_RATE = 30.5;
final double LAST_TIER_RATE = 22.5;
final int NEXT_TIER_START_DAY=4;
final int LAST_TIER_START_DAY=7;
double rental= 0.0;
int days = 0;
if(days<NEXT_TIER_START_DAY){
rental=days*BASE_RATE;
}
else if(days<=LAST_TIER_START_DAY){
rental=3*BASE_RATE+(days-3)*NEXT_TIER_RATE;
}
else{
rental=3*BASE_RATE+4*NEXT_TIER_RATE+(days-7)*LAST_TIER_RATE;
}
return rental;
}
}`
以下是GUI类。
哔哔one
www说
幕布斯6054654
相关分类