What to do: Create a project consisting of four classes. These four classes will be ProgThree.java, Animal.java, Pet.java, and ZooAnimal.java. You must have these four classes and they must work as it is described in these specifications. You may add other classes and methods if you consider them necessary.

This assignment requires you to implement at least four classes. The first class, Animal, stores basic data about an animal. The second class Pet, stores additional data about an animal which is a pet. The third class ZooAnimal, stores additional data about an animal which is kept in a zoo. The fourth class ProgThree has a main method which reads data about animals, pets and zoo animals and creates a report about animals, pets and zoo animals.

Your program must be developed following the guidelines previously discussed in class. These guidelines include appropriate variable names, use of comments to describe the purpose of the program and the purpose of each method, and proper use of indentation of all program statements.

Animal.java technical details:

Constructor #1. It will take all the parameters as listed:

int animalID.
String animalType.
double weight.

Instance variables for the Animal class

int animalID.
String animalType.
double weight.

Method which must be part of the Animal class:

A toString() method which displays information about an animal in the following format:

ID: 1015 Type: Monkey Weight: 38.6

Pet.java technical details:

One Constructor the first three parameters are passed to the Animal class constructor in the first line of the Pet constructor by using the super reference.

Constructor. It will take all the parameters as listed:
int animalID.
String animalType.
double weight.
String name;
String owner:

Instance variables for the Pet class

String name;
String owner;

Method which must be part of the Pet class:

A toString() method which displays information about an animal in the following format:

ID: 5089 Type: Fish Weight: 0.2
Name: Sally Owner: Henry Santos

Note: The toString() Method gets the first line of output from the Animal class toString method.

Animal is a parent class of the Pet class.

ZooAnimal.java technical details:

One Constructor the first three parameters are passed to the Animal class constructor in the first line of the ZooAnimal constructor by using the super reference.

Constructor #1. It will take all the parameters as listed:
int animalID.
String animalType.
double weight.
int cageNumber.
String trainer.

Instance variables for the ZooAnimal class

int cageNumber.
String trainer.

Method which must be part of the ZooAnimal class:

A toString() method which displays information about an animal in the following format:

ID: 8850 Type: Fish Weight: 0.2
Cage: 103 Trainer: Suzie Tran

Note: The toString() Method gets the first line of output from the Animal class toString method.

Animal is a parent class of the ZooAnimal class.

ProgThree.java Specifications:

ProgThree should read information about animals, pets and zoo animals. Initial data about pets is available in a text file named animal.txt. The program should read one line of input from the text file and process it independently. The program should continue until all lines of the input file have been processed.

The input file will contain a single line of data about each animal, pet or zoo animal. There are several lines in the input file and the animals, pets and zoo animals are mixed together. A input line will either contain three or five pieces of data. An input line with three pieces of data is an animal, and those three pieces of data will be animal id, type and weight, in order. Pets and zoo animals have the same first three pieces of data and then two additional pieces of data. If the animal id is between 3,000 and 7,999 the input record is about a pet and the last two pieces of data are the pets name and the owners name, both strings. If the animal id is between 8,000 and 9,999 the input record is about a zoo animal and the last two pieces of data are the cage number, an integer and the trainers name, a string.

The rules for valid input records, follow:

The first piece of data is animalID. It must be a four digit positive integer. Records whose ID numbers are between 3,000 and 7,999 should contain data about a pet. Records whose ID numbers are between 8,000 and 9,999 should contain data about a zoo animal. Records whose ID numbers are between 1,000 and 2,999 should contain data about an animal. Records whose ID numbers are less than 1,000 or greater than 9,999 should be considered to be invalid records.

animalType must be a string of at least three characters.

weight must be a valid positive real number.

For Pet objects, name and owner each must be strings of at least three characters.

For Zoo Animal objects, cageNumber must be a positive integer and trainer must be a string of at least three characters.

You may assume that input records will contain data of the data types needed by the program. For example, for input records of animals the record will contain an int, String and double in that order. You may not assume, however, that the input records will contain valid data. For example, the weight will be a real number (data type matches) but it may be negative making the input record invalid. In another input record, the animalType is a string but only contains two characters, making it an invalid record.

After reading in the data, determine if the data contained in the record is valid. If so, construct the appropriate type of object and write the objects data to the output file, animalout.txt. If not, ignore the input record and proceed to the next record. When all of the animals have been processed, write to the output the total number of each, animals, pets and zoo animals written to the output file. Close the output file and end the program. You will need to use skills learned in modules two through seven and ten to complete this program.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.