Trying to create a project that uses user input and known information to determine how much a car rental costs per day. The problem I'm having is the CarRental class doesn't seem to be getting the input from the test class. Not sure how to solve it.
class CarRental
public class CarRental {
private String customerName;
private String ratingKey;
private double baseFactor;
private double basefactor;
private double fudge;
private double computeDailyFee;
public CarRental(String customerName, String ratingKey, double baseFactor, double fudge, double computeDailyFee) {
this.customerName = customerName;
this.ratingKey = ratingKey;
this.baseFactor = baseFactor;
this.basefactor = basefactor;
this.fudge = fudge;
this.computeDailyFee = computeDailyFee;
//intitialize
}
public String getcustomerName() {
return this.customerName;
}
public String getratingKey() {
return ratingKey;
}
public void setcustomerName(String newCustomerName) {
customerName = newCustomerName;
System.out.println(customerName);
}
public void setratingKey(String newRatingKey) {
ratingKey = newRatingKey;
System.out.println(ratingKey);
}
public double baseFactor() {
switch (ratingKey.charAt(0)) {
case 'S':
baseFactor = 1.0;
break;
case 'C':
baseFactor = 1.2;
break;
case 'U':
baseFactor = 1.4;
break;
case 'T':
baseFactor = 1.6;
break;
case 'B':
baseFactor = 2.0;
break;
default:
System.out.println("Invalid type");
break;
}
System.out.println(baseFactor);
return baseFactor;
}
public double fudge() {
switch (ratingKey.charAt(1)) {
case 'N':
fudge = 11.40;
break;
case 'V':
fudge = 0;
break;
default:
System.out.println("Invalid type");
break;
}
System.out.println(fudge);
return fudge;
}
public double computeDailyFee() {
computeDailyFee = (baseFactor() * (89.22 - fudge()));
System.out.println(computeDailyFee);
return computeDailyFee;
}
}
class RentalTest
public class RentalTest {
public static void main(String[] args) {
CarRental rental = new CarRental("customerName", "ratingKey", 0.0, 0.0, 0.0);
String newCustomerName = rental.getcustomerName();
String newCustomerName = JOptionPane.showInputDialog("Enter your name");
//System.out.println(newCustomerName);
RentalTest rentaltest = new RentalTest();
JOptionPane.showMessageDialog(null, "Input code for model, then code for condition (No Spaces)");
String newRatingKey = JOptionPane.showInputDialog(
"Models: 'S' = Sub-compact 'C'=Car 'U'=SUV 'T'=Truck 'B'=Bigfoot\n"
+ "Condition: 'N'= New 'V' = Vintage");
newRatingKey = newRatingKey.toUpperCase();
//System.out.println(newRatingKey);
}
}