I have an assignment and I completed my code for it, but the issue remains that the Car type and the total fee are coming up blank at the end when I run it, It has to do with inheritance which is something new to me and I hope I did it right. The program is in 3 separate classes, any help would be greatly appreciated
import java.util.*;
public class UseCarRental {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("How many days do you need the rental?");
int rentalLength = input.nextInt();
System.out.println("Enter requested car size:" +
"\nEconomy" + "\nMidsize" + "\nFullsize" + "\nLuxury");
String rentalCarSize = input.nextLine();
input.next();
CarRental firstRental = new CarRental(rentalLength, rentalCarSize);
firstRental.display();
}
}
class CarRental {
public String rentalCarSize = "";
public double rentalFeeDaily;
public int rentalLength = 0;
public double rentalFeeTotal= rentalFeeDaily*rentalLength;
public CarRental(int days, String carSize)
{
rentalCarSize = carSize;
rentalLength = days;
}
public void display()
{
System.out.println(
"#############" +
"\nCar Size = " + getRentalCarSize() +
"\nRental Length = " + rentalLength +
"\nTotal Fee = " + rentalFeeTotal
);
}
public void setRentalLength(int length)
{
rentalLength = length;
}
public String getRentalCarSize()
{
return rentalCarSize;
}
public int getRentalLength()
{
return rentalLength;
}
public double getRentalFeeTotal()
{
return rentalLength * rentalFeeDaily;
}
public double getRentalFeeDaily(String carSize)
{
switch (carSize)
{
case "Economy":
rentalFeeDaily = 29.99;
break;
case "Midsize":
rentalFeeDaily = 38.99;
break;
case "Fullsize":
rentalFeeDaily = 43.50;
break;
case "Luxury":
rentalFeeDaily = 79.99;
break;
}
return rentalFeeDaily;
}
}
import javax.swing.*;
public class LuxuryCarRental extends CarRental
{
public LuxuryCarRental(int days, String carSize)
{
super(days, carSize);
}
@Override
public void display()
{
JOptionPane.showMessageDialog(null,
"\nCar Size = " + getRentalCarSize() +
"\nRental Fee = " + rentalFeeDaily +
"\nRental Length = " + rentalLength +
"\nTotal Fee = " + rentalFeeTotal);
}
}