Question
Task: Implement the Zoo and Animal classes, and then answer the questions at the end of the document. Class Design: Zoo A zoo contains a
Task: Implement the Zoo and Animal classes, and then answer the questions at the end of the document.
Class Design:
Zoo A zoo contains a collection of animals. We can add animals one at a time to the zoo by providing a single Animal object (addAnimal(Animal a)), or we can add multiple animals by providing the animals.dat file (addAnimals(String filename)). Among the methods provided by the Zoo class are:
Provide all the Animal objects that can fly in the zoo.
Provide all the Animal objects that can swim in the zoo.
Provide all the Animal objects that can walk in the zoo.
Provide all the Animal objects that breathe through their lungs in the zoo.
Provide all the Animal objects that breathe through their gills in the zoo.
Provide all the Animal objects that lay eggs in the zoo.
Provide all the Animal objects that are born through live birth in the zoo.
Provide all the cold blooded Animal objects in the zoo.
Provide all the warm blooded Animal objects in the zoo.
Provide all the Animal objects covered in fur in the zoo.
Provide all the Animal objects weighing more than particular weight.
Provide all the Animal objects weighing less than particular weight.
Provide all the Animal objects of a particular species.
Provide all the Animal objects with a particular name.
toString() a complete String description of the zoo.
toShortString() just the name and species of the zoo. For example, Lisa the lion
Animal An animal is a living creature. Each animal has a name, species, & weight. An animal may be able to fly, swim, or walk. An animal can breathe either through lungs or through gills. A mother animal can deliver babies either though laying eggs or through live birth. Animals are either cold or warm blooded. Their skin may be covered with fur.
Animal.dat a datafile with a collection of animals to put in the zoo. Each line in the file is used to construct an animal that can be added in the zoo. Each line contains a group of fields that are used to define the animal. Each field in the line is separated by a comma. The fields on each line are, in order from the start of the line to the end, are: name, species, weight, how it moves (fly, swim, walk), how it breathes (lungs, gills), how it gives birth (eggs, live), blood temperature (hot, cold), and skin covering (fur, feathers, scales)
Animal.dat
ZooKeeper The zookeeper admits animals into the zoo and keeps track of the animals in it. It is the only class in this project with a main() method, and the only method in this class is main.
Tasks:
Implement the Animal class. Put this class in the package edu.your.zoo
Implement the Zoo class. Put this class in the package edu.your.zoo
Build a ZooKeeper class. In its main() method, do the following tasks:
Construct a Zoo object.
Add the animals in Animal.dat using the addAnimals() method in Zoo
Add any three animals of your choice using the addAnimal() method in Zoo
Print the name and species of all the animals in the zoo that lay eggs.
Print the name and species of all the animals in the zoo that are cold blooded
Print the name and species of all the animals in the zoo that breathe through their gills
Print the name and species of all the animals in the zoo that lay eggs.
Print the toString() for the animal named Lisa
How many animals are in the zoo?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started