Computers and Technology

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

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 16:40, kaileyy06
Match each feature of e-publishing as an advantage, a disadvantage, a threat, or an opportunity. (choices) increased collaboration digitalized out-of-print versions monopoly over digital formats requirement for a specialized digital device pairs advantage of e-publishing disadvantage of e- opportunity for e- threat to e-
Answers: 1
image
Computers and Technology, 23.06.2019 11:50, itaheart101
While preforming before operation pmcs, you notice the front right tire appears slightly under-inflated. what is the proper action?
Answers: 3
image
Computers and Technology, 23.06.2019 17:30, Artemis3821
Scientists have changed the model of the atom as they have gathered new evidence. one of the atomic models is shown below. what experimental evidence led to the development of this atomic model from the one before it? a few of the positive particles aimed at a gold foil seemed to bounce back. the colors of light emitted from heated atoms had very specific energies. experiments with water vapor showed that elements combine in specific proportions. cathode rays were bent in the same way whenever a magnet was brought near them.
Answers: 2
image
Computers and Technology, 24.06.2019 08:20, bob4059
Evaluate the scenario below and indicate how to handle the matter appropriately. situation: michael received an e-mail from what he thought was his doctor’s office, requesting his social security number. since he had just been in to see his doctor last week, he replied to the e-mail with his social security number.
Answers: 2
Do you know the correct answer?
Assignment: You are to create seven classes that represent a Zoo. The classes are define as follows...

Questions in other subjects:

Konu
Mathematics, 27.03.2020 02:50