Question
This assignment must be done in Java. Main Task Use a factory pattern to support a rental car program Create RentalCar class, with following attributes
This assignment must be done in Java.
Main Task
Use a factory pattern to support a rental car program
Create RentalCar class, with following attributes
Name
# 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
Toyota Corolla, 4
Dodge Minivan, 7
Ford Escape Hybrid, 5
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()
Extra Credit
Use the observer pattern to support a mythical broadcast system
Create a Broadcaster class that supports:
void register (Receiver r) objects of type Receiver can register
void broadcast (String message) sneds message to all registered Receivers
The Receiver class should support:
Receiver(String name) constructor that sets the name
void receive (String message) accepts messages sent to it and prints them out
Write a Test class that does the following in its main()
This should result in the output below
for iStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started