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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 03:30, raytaylorh010801
Write a computer program to calculate the three-phase fault current for a fault at f in figure 1.16, with the network normal, and with one line at a time removedproblems 1.1 write a computer program to calculate the three-phase fault current for a fault at f in figure 1.16, with the network normal, and with one line at a time removed 20 power system relaying from service. the positive-sequence impedance data are given in the accompanying table. use the commonly made assumption that all prefault resistance values are (1.0+j0.0) pu, and neglect all resistance values. calculate the contribution to the fault flowing through the cb b and the voltage at that bus. for each calculated case, consider the two possibilities: cb b2 closed or open. the latter is known as the stub-end fault í• figure 1.16 problem 1.1 system data for figure 1.16 from to positive sequence 0.0+j0.1 0.05j0.15 0.04 j0.2 0.01 jo. i 0.015 + j0.15 0.01 j0.19 0.01 +j0.19 0.03+j0.1 0.0+j0.08 6 6 6 from service. the positive-sequence impedance data are given in the accompanying table. use the commonly made assumption that all prefault resistance values are (1.0 + j 0.0) pu, and neglect all resistance values. calculate the contribution to the fault flowing through the cb b1, and the voltage at that bus. for each calculated case, consider the two possibilities: cb b2 closed or open. the latter is known as the “stub-end” fault.
Answers: 2
image
Computers and Technology, 22.06.2019 03:30, juliannxkim
Which group on the home tab allows you to add shapes to a powerpoint slide?
Answers: 1
image
Computers and Technology, 22.06.2019 09:30, caldonjoshhsms2061
What are the steps involved in accepting all the changes in a document? arrange these in order click edit. click accept or reject. click changes. click accept all.
Answers: 1
image
Computers and Technology, 22.06.2019 18:10, o10922025
Assume that to_the_power_of is a function that expects two int parameters and returns the value of the first parameter raised to the power of the second parameter. write a statement that calls to_the_power_of to compute the value of cube_side raised to the power of 3 and that associates this value with cube_volume.
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 in other subjects: