Question: ***IN JAVA*** Write a program where a user populates a collection of various cats and dogs. The user should be able to specify which type
***IN JAVA***
Write a program where a user populates a collection of various cats and dogs. The user should be able to specify which type they wish to enter, and then are prompted with the pertinent information for every type of pet.
Requirements:
The structure of the program should follow this UML class diagram.
You may also include helper methods and attributes that are not noted in the class.
Additional Notes:
The weight for animal should be strictly greater than 0
The mood for a cat should either be sleepy, playful, or hungry
The energy level for a dog should be between 0 and 100 inclusively
The type of house cat should one of the following
Short Hair
Bombay
Ragdoll
Sphinx
Scottish Fold
The type of domestic dog should be one of the following
Retriever
Terrier
Husky
Yappy
Mutt
In addition to whats specified in the UML diagram, the classes, Animal, Cat, Dog, HouseCat, Leopard, Domestic Dog, and Wolf must have
Constructors (Both default and parameterized)
Accessors and Mutators
A toString method
An equals method
In addition to whats specified in the UML diagram, AnimalCollection only needs a default constructor which will set the array of animals to some constant default size. Also no Accessors or Mutators.
Remember the block arrows are the is a relationship so it means inheritance
The line arrows are the has a relationship so it contains one or more instances of that class
Example Output:
Welcome to the Cat and Dog Collection!
Would you like to
1. Add a cat or dog
2. Remove a cat or dog
3. Quit
Enter a selection
1
Would you like to add a 1. House Cat, 2. A Leopard, 3. A Domestic Dog, or 4. A wolf
1
Enter the house cat's name, weight, mood, and type
Roscoe
20
Hungry
Bombay
Current Collection
Name: Roscoe Weight: 20.0 Mood: Hungry Type: Bombay
Would you like to
1. Add a cat or dog
2. Remove a cat or dog
3. Quit
Enter a selection
1
Would you like to add a 1. House Cat, 2. A Leopard, 3. A Domestic Dog, or 4. A wolf
3
Enter the domestic dog's name, weight, energy level, and type
Maggie
50
75
Retriever
Current Collection
Name: Roscoe Weight: 20.0 Mood: Hungry Type: Bombay
Name: Maggie Weight: 50.0 Energy Level:75 Type: Retriever
Would you like to
1. Add a cat or dog
2. Remove a cat or dog
3. Quit
Enter a selection
1
Would you like to add a 1. House Cat, 2. A Leopard, 3. A Domestic Dog, or 4. A wolf
2
Enter the leopard's name, weight, mood, and number of spots
Chester
200
Playful
100
Current Collection
Name: Roscoe Weight: 20.0 Mood: Hungry Type: Bombay
Name: Maggie Weight: 50.0 Energy Level:75 Type: Retriever
Name: Chester Weight: 200.0 Mood: Playful Number of Spots: 100
Would you like to
1. Add a cat or dog
2. Remove a cat or dog
3. Quit
Enter a selection
1
Would you like to add a 1. House Cat, 2. A Leopard, 3. A Domestic Dog, or 4. A wolf
4
Enter the wolf's name, weight, energy level, and type
Ghost
200
90
Jon Snow
Current Collection
Name: Roscoe Weight: 20.0 Mood: Hungry Type: Bombay
Name: Maggie Weight: 50.0 Energy Level:75 Type: Retriever
Name: Chester Weight: 200.0 Mood: Playful Number of Spots: 100
Name: Ghost Weight: 200.0 Energy Level:90 Pack Leader Name: Jon Snow
Would you like to
1. Add a cat or dog
2. Remove a cat or dog
3. Quit
Enter a selection
2
Enter the animal's name that is to be removed
Chester
Current Collection
Name: Roscoe Weight: 20.0 Mood: Hungry Type: Bombay
Name: Maggie Weight: 50.0 Energy Level:75 Type: Retriever
Name: Ghost Weight: 200.0 Energy Level:90 Pack Leader Name: Jon Snow
Would you like to
1. Add a cat or dog
2. Remove a cat or dog
3. Quit
3
Goodbye!
AnimalCollection AnimalFrontEnd animals: Animall + addAnimal(Animal): void + removeAnimal(String): void + printAnimals():void + static main(Stringll args):void Animal -name: String -weight: double Cat Dog -mood: String -energyLevel: int HouseCat Leopard numberOfSpots: int DomesticDog Wolf -type: String -type: String -packLeaderName: StringStep by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
