} public interface ICar
;()double getPrice
{
} public abstract class CarRent implements ICar
;protected String type
;protected String color
} public CarRent(String type, String color)
;this.type = type
;this.color = color
{
;()public abstract double getPrice
Override@
} ()public String toString
;()return "Type: " + type + ", Price: " + getPrice
{
{
} public class Days extends CarRent
;private int noOfDays
} public Days(String type, String color, int noOfDays)
;super(type, color)
;this.noOfDays = noOfDays
{
Override@
} ()public double getPrice
;return noOfDays * 100
{
Override@
} ()public String toString
;return super.toString() + ", No. of Days: " + noOfDays
{
{
} public class Months extends CarRent
;private int noOfMonths
} public Months(String type, String color, int noOfMonths)
;super(type, color)
;this.noOfMonths = noOfMonths
{
Override@
} ()public double getPrice
;return noOfMonths * 1500
{
Override@
} ()public String toString
;return super.toString() + ", No. of Months: " + noOfMonths
{
{
} public class CarRentalApplication
} public static void main(String[] args)
;CarRent carRent1 = new Days("Sedan", "Red", 5)
;CarRent carRent2 = new Months("SUV", "Blue", 2)
;System.out.println(carRent1.toString())
;System.out.println(carRent2.toString())
{
{