Lab 4
USF Zoo Database
Due Wednesday, March 22 11:55pm. Submission through SVN.
Please submit your work in SVN directoryhttps://www.cs.usfca.edu/svn/< your username >/cs112/lab4
e.g. https://www.cs.usfca.edu/svn/ejung/cs112/lab4
Goal
Design and implement a database for USF Zoo. You will be practicing inheritance and visibility modifiers to take advantage of common traits of Mammals and Reptiles. You can pick your favorite animals to put in the zoo. There has to be at least 2 mammals and 2 repitles in your zoo. Implement Driver that instantiates objects of each class, and prints their information.
Specifications
- Create a usfzoo package for this project.
- (5%) Implement USFZoo class with the following variables.
- public static final String zooName = "USF Zoo";
- protected static int totalAnimals = 0;
- (5%) Implement Mammals class with the following variable.
- protected static int totalMammals = 0;
- (5%) Implement Reptiles class with the following variable.
- protected static int totalReptiles = 0;
- (10%) Implement two animal classes that are subclasses of Mammals. In each class, you need the following statements in the constructor to keep the animal count up to date.
- totalMammals++;
- totalAnimals++;
- (10%) Implement two animal classes that are subclasses of Reptiles. In each class, you need the following statements in the constructor to keep the animal count up to date.
- totalReptiles++;
- totalAnimals++;
- (20%) Each subclass of Mammals and Reptiles has the following variables. Initialize all instance variables in the constructor, and provide getters and setters for height and weight. Initialize scientificName in each class.
- public static final String scientificName;
- public final String nickName;
- private float height;
- private float weight;
- (10%) Provide toString method in each subclass of Mammals and Reptiles that returns the String representation of its scientific name, nickname, height and weight.
- (30%) In Driver, instantiate at least one object of each subclass of Mammals and Reptiles.Print the total number of animals, mammals, and reptiles using the protected variables totalAnimals, totalMammals, and totalReptiles. Print the information of each object using toString method.
- (5%) Write README that explains how your program works, and how inheritance and visibility modifier helps you. For example, what is the benefit of having scientificName as public final static? What is the benefit of having totals as protected static?
What to submit
Submit README, Driver.java, USFZoo,java, Mammals.java, Reptiles.java, and your 4 animal classes to your SVN.