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 21:30
The graph shows median weekly earnings for full-time workers according to education level. which can you not conclude?
Answers: 2
question
Computers and Technology, 22.06.2019 23:30
What does 21 pilots middle aged name as a band 15 years prior to them naming their band 21 pilots?
Answers: 1
question
Computers and Technology, 23.06.2019 00:40
Consider the following statements: struct nametype{string first; string last; }; struct coursetype{string name; int callnum; int credits; char grade; }; struct studenttype{nametype name; double gpa; coursetype course; }; studenttype student; studenttype classlist[100]; coursetype course; nametype name; mark the following statements as valid or invalid. if a statement is invalid, explain why.a.) student.course.callnum = "csc230"; b.) cin > > student.name; c.) classlist[0] = name; d.) classlist[1].gpa = 3.45; e.) name = classlist[15].name; f.) student.name = name; g.) cout < < classlist[10] < < endl; h.) for (int j = 0; j < 100; j++)classlist[j].name = name; i.) classlist.course.credits = 3; j.) course = studenttype.course;
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
What key should you press and hold to select and open multiple files at one time? enter alt control esc
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, 24.09.2020 14:01
question
Social Studies, 24.09.2020 14:01
question
Physics, 24.09.2020 14:01
question
Mathematics, 24.09.2020 14:01
Questions on the website: 13722363