Question
use Java Part #1: Use the Factory pattern to address the following challenge ( 5 points ) Your job is to make it easy to
use Java Part #1: Use the Factory pattern to address the following challenge ( 5 points ) Your job is to make it easy to obtain a Pet from a factory-like class Pet is an abstract class that has 2 attributes Name Sound You should create 3 concrete types of pets Parakeet (makes the sound "Tweet tweet") Dog (makes the sound "Woof woof") Lion (makes the sound "Roar roar") You should create a factory class that allows the caller to create pets by specifying Name Acres of land where pets will live The # of acres of land determines what kind of pet is assigned 1 acre or less: parakeet 4 acre of less: dog 9 acre or less: lion Smaller pets are always preferred over larger ones For example if the caller has 2 acres, then a new Dog should be returned Your solution should minimally include 6 classes: The abstract Pet and concrete classes (4 classes) Factory class (1 class) An additional Test class Should demonstrate getting pets for the following acre sizes: 0, 3, 7 For each pet retrieved, print out its sound (to the output) Part #2: Choose ONE of the below challenges and solve it with one of the patterns we learned (5 points ) Option #1: Use the Decorator pattern to implement a photo booth There should be an abstract Photo class Has an abstract cost() method that returns the cost of the photo There should be 2 types of photos Color: $1 Black and white: $2 Each photo has the following options: Frame: extra $2 Glossy: extra $1 Digitally corrected: extra $4 Write a test class that demonstrates the creation of two instances of photos (using the decorator pattern we covered in class): A color one that is framed and glossy A black and white one that is extra glossy (apply glossy twice) and has been digitally corrected The test class should also demonstrate printing out the true cost of each of the 2 photo configurations specified in the previous instruction Option #2: Use the Observer pattern to improve communication between a Mayor and its citizens A Mayor has a name can do two types of things Add new citizens to his/her mailing list Make announcements When making announcements, a mayor e-mails each of their citizens e-mails that contain: Mayor
Step 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