Question: #Java Question Use a factory pattern to support a rental car program Create RentalCar class, with following attributes o Name o # of people can
#Java Question
Use a factory pattern to support a rental car program
Create RentalCar class, with following attributes
o Name
o # of people can fit
Write a toString() method for the RentalCar class so that it prints out the name of the car and the # of people that can fit
Create 4 types of rental cars:
o Toyota Corolla, 4
o Dodge Minivan, 7
o Ford Escape Hybrid, 5
o Yamaha Motorcycle, 1
Create a RentalCarFactory class that takes number of people as a parameter and returns the smallest car that will fit everyone
Write a Test class that does the following in its main()
for (int i=1; i<7; i++) {
RentalCar car = RentalCarFactory.rent(i);
System.out.println( "Car that holds + i + " people: "+car); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
