subject

Assignment: You are to create seven classes that represent a Zoo. The classes are define as follows:
1. Zoo
2. Enclosure
3. Animal
4. Crocodile
5. Gazelle
6. Lion
7. Zebra
1. Zoo:
Required member variables:
private String name;
private String address;
private Enclosure[] enclosures;
private int area;
private double budget;
2. Enclosure:
Required member variables:
private String biome;
private Animal[] animals;
3. Animal
Required member variables:
private String name;
private String genus;
private String species;
private Zoo currentZoo;
protected Animal enemy;
protected String prefferedBiome;
For classes 4-7, there are no required member variables.
All the classes must have getters and setters for each of their member variables. All of the classes must have overridden toString() and equals(...) functions. All classes must be in separate files. Crocodile, Gazelle, Lion and Zebra are Animals. Class Animal must implement this interface:
interface
Feedable
{
void
getFeedingInstructions();
void
feed();
}
All the child classes of Animal must have its own overridden
getFeedingInstructions();
and
feed();
functions.
The classes need to be implemented in a way that makes this main function:
public static void main(String[] args) {
//Creating a new Zoo.
Zoo laZoo = new Zoo("Los Angeles Zoo", "5333 Zoo Dr, Los Angeles, CA 90027", 133, 0);
//Creating two different Enclosures.
Enclosure firstEnclosure = new Enclosure("Savanna");
Enclosure secondEnclosure = new Enclosure("River");
//Creating our animals.
Zebra zeb = new Zebra("Zebby");
Gazelle gaz = new Gazelle("Gaz");
Crocodile croc = new Crocodile("Gena");
Lion leo = new Lion("Leo");
//Trying to add croc to the firstEnclosure, but Crocodiles can't live in the Savannah, so it prints an error message.
firstEnclosure. addAnimal(croc);
//Adding leo to the first enclosure.
firstEnclosure. addAnimal(leo);
//Adding croc to the second enclosure.
secondEnclosure. addAnimal(croc);
//Trying to add zeb to the secondEnclosure, but Crocodiles and Zebras are enemies, so it prints an error message.
secondEnclosure. addAnimal(zeb);
//Creating a new enclosure just for the herbivores.
Enclosure thirdEnclosure = new Enclosure("Savanna");
//Adding zeb and gaz to the third enclosure.
thirdEnclosure. addAnimal(zeb);
thirdEnclosure. addAnimal(gaz);
//Adding all three enclosures to the zoo.
laZoo. addEnclosure(firstEnclosure);
laZoo. addEnclosure(secondEnclosure);
laZoo. addEnclosure(thirdEnclosure);
//Printing the Zoo:
System. out. println(laZoo);
//Getting the feeding instructions for all the animals:
laZoo. getFeedingInstructions();
//Feeding the animals:
laZoo. feed();
//However, an error message is printed because the Zoo doesn't have enough money to feed all the animals,
so we add more money to the Zoo.
laZoo. setBudget(999999999);
//Successfully feeding the animals!
laZoo. feed();
}
Output this:
Error! Gena cannot live in the Savanna. addAnimal failed.
Error! Zebby cannot live with Gena, as they are enemies. addAnimal failed.
Los Angeles Zoo

Address: 5333 Zoo Dr, Los Angeles, CA 90027
Area: 133

Enclosures:
1. Savanna:
a) Leo (Panthera leo)
2. River:
a) Gena (Crocodylus niloticus)
3. Savanna:
a) Zebby (Equus quagga)
b) Gaz (Rhim gazelle)
How to Feed:
1. Savanna:
a) Meat 4000$
2. River:
a) Meat 5000$
3. Savanna:
a) Grass 600$
b) Grass 900$
Feeding failed! Out of funds.
Feeding completed successfully.
Submitting the assignment:
You must upload the assignment to canvas as a set of these 9 files in a
SINGLE
zip file called
last_first_Project2.zip
Main. java
Feedable. java
Zoo. java
Enclosure. java
Animal. java
Crocodile. java
Gazelle. java Lion. java
Zebra. java

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:30
What type of computer network ensures high security ?
Answers: 1
question
Computers and Technology, 22.06.2019 08:00
Two technicians are discussing the common u-joint. technician a says its input and output speeds should be equal. technician b says that it normally has two yokes. which technician is correct?
Answers: 1
question
Computers and Technology, 22.06.2019 19:10
10. when you create a pivottable, you need to specify where to find the data for the pivottable. is it true
Answers: 2
question
Computers and Technology, 23.06.2019 00:00
Which is the correct sequence of steps to set up a document in landscape orientation? a. select page setup from the file menu. then click the margins tab and select landscape. b. select page setup from the edit menu. then click the margins tab and select landscape. c. select page setup from the insert menu. then click the margins tab and select landscape. d. select page setup from the format menu. then click the margins tab and select landscape
Answers: 1
You know the right answer?
Assignment: You are to create seven classes that represent a Zoo. The classes are define as follows...
Questions
question
Mathematics, 29.07.2020 07:01
question
Mathematics, 29.07.2020 07:01
question
Biology, 29.07.2020 07:01
question
Advanced Placement (AP), 29.07.2020 07:01
question
English, 29.07.2020 07:01
question
Mathematics, 29.07.2020 07:01
question
English, 29.07.2020 07:01
Questions on the website: 13722363