Question: Java Progaming Question We will be creating a virtual Zoo. Just like a real Zoo, ours will have a name and will be made up
Java Progaming Question
We will be creating a virtual Zoo. Just like a real Zoo, ours will have a name and will be made up of Exhibits that people will come to see their favorite animals at. Our virtual Zoo will have four (4) Exhibits:
Aquatic
Bear
Reptile
Bird
Each exhibit has a name and for our case, will have two different animals in each exhibit. To keep things simple for us, our Animals at our Zoo will only have a name and a voice. A voice will be a text representation of what noise they make (e.g. the voice of a Pig would be Oink).
Create a new project and name it Zoo
Our Zoo project will have 4 Classes in it (25 pts each)
Animal - This will be our class to represent an Animal. This will be the same class that you created in Homework 5.
Exhibit - This will be our class to represent an exhibit at our Zoo (like a dolphin show or something). Our Exhibit will have a name and two (2) animals associated with it
Zoo - This will be our class to represent our Zoo. Our Zoo will have a name and four (4) Exhibits (feel free to make more than that if you want!).
Driver - This will be our class with our main() method to create our Zoo and set everything up.
Create a new instance of your Zoo object.
You will need to create Create four (4) exhibits to make our Zoo (aquatic, bear, reptile, and bird).
You will need to create and add two (2) animals to each exhibit. Have fun with which animals you put in which exhibit and what their voice is if you want (aka the animals dont have to make perfect sense for the exhibit you add them to) but do make sure that you do not just use the same animals for every exhibit.
Once you have your Zoo object fully populated, call the visitAllExhibits() method.
Use the given UML Diagrams to create your classes:
| Animal | |
| - - | name : String voice : String |
| + + + + + + + | Animal ( ) Animal ( name : String, voice : String ) getName ( ) : String setName ( name : String ) : void getVoice ( ) : String setVoice ( voice : String ) : void talk ( ) : String |
| Talk will return the result of the name of the animal and the voice field. e.g. {name of the animal} says {voice} | |
| Exhibit | |
| - - - | exhibitName : String firstAnimal : Animal secondAnimal : Animal |
| + + + | Exhibit ( ) Exhibit ( name : String, firstAnimal : Animal, secondAnimal : Animal) startExhibit() : void |
| The startExhibit method will need to write 2 lines out to the console: The {name of exhibit} exhibit is now starting, where {name of exhibit} will be the name assigned to the Class variable name Call the talk() method on the firstAnimal and then concatenate a space ( ) and then concatenate the value returned from calling the talk() method on the secondAnimal Generate getters and setters for all of the instance variables. | |
| Zoo | |
| - - - - - | zooName : String aquaticExhibit : Exhibit bearExhibit : Exhibit reptileExhibit : Exhibit birdExhibit : Exhibit |
| + + + | Zoo ( ) Zoo( zooName : String ) visitAllExhibits ( ) : void |
| The visitAllExhibits method will call all 4 exhibits that make up our Zoo and will call the startExhibit() method on each one.
Feel free to create an additional constructor that takes all your instance variables if you want for your own testing purposes, just make sure that you have the 2 that are required.
| |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
