Assignment: A large veterinarian services many pets and their owners. As new pet
ID: 3683288 • Letter: A
Question
Assignment:
A large veterinarian services many pets and their owners. As new pets are added to the population of pets being serviced, their information is entered into a flat text file. Each month, the vet requests a listing of all pets sorted by their outstanding bill balance. You have to write a program to produce a report of animals and their owners sorted by their outstanding balances from the data in the flat text file, as follows.
Part 1 (50 points)
A class named Animal with the following details/subclasses.
– owner name: a character string – birth year: numeric
– bill balance: numeric
– species: a character string
A subclass of Animal named Mammal with the following details. – number of legs: numeric
A subclass of Animal named nonMammal with the following details. – blood type: a character string
Constructor method(s) of all classes.
Accessor and mutator (get and set) methods of all classes.
Override the toString() and compareTo() methods of all classes. The compareTo() must compare according to bill balance.
Part 2 (50 points)
• A class named VetShop with the following details
– clients: an array of Animal objects
– A simple main method that calls the following input, sort, and report methods.
– An input method to fill the clients array with Animal objects created with the information in the input text file attached. The first line has the number of clients, followed by the data of one animal in each line.
– A method to sort the array of Animals by bill balance.
– A method to produce an output report with one Animal per line.
Explanation / Answer
class Animal
{
public String owner_name;
public String species;
public int year;
public float balance;
public Animal(String owner_name1, String species1, int year1, float balance1)
{
owner_name = owner_name1;
species = species1;
year = year1;
balance =balance1;
}
String getOwnerName()
{
return owner_name;
}
void setOwnerName(String owner_name1)
{
owner_name = owner_name1;
}
String getSpeice()
{
species = species1;
}
void setSpeices(String Speices1)
{
species = Speices1;
}
int getYear()
{
return year;
}
}
class Mamal extends Animal
{
public int legs;
}
class nonMamal extends Anima
{
public String blood_type;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.