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()

This assignment must be done in Java. Main Task Use a factory

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()

pattern to support a rental car program Create RentalCar class, with following

This should result in the output below

attributes Name # of people can fit Write a toString() method for

for i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!