Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

image text in transcribed

This should result in the output below

image text in transcribed

for i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions