Question: Concepts: Classes and objects, inheritance, polymorphism Assignment: A veterinarian services many pets and their owners. As new pets are added to the population of pets
Concepts: Classes and objects, inheritance, polymorphism
Assignment:
A 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 bill balances from the data in the flat text file. Below is a description of the information on the text file:
The first line on the file contains the number of animals on the file (numeric)
The fields below repeat for each animal:
Owner name (String)
o Birth year (numeric)
o Bill balance (numeric) o Species (String)
o Special feature (could be numeric or String)
The animals serviced by the veterinarian are of two types: mammals and non-mammals. For a mammal the special feature field on the flat file is the number of legs of the animal (numeric). For a non-mammal the special feature field is the blood type, warm-blooded or cold-blooded (String).
Program requirements and grading:
From the information provided, write a solution that includes the following:
A suitable inheritance hierarchy which represents the pets serviced by the veterinarian. It is up to you how to design the inheritance hierarchy. I suggest an Animal class and appropriate subclasses.
For all classes include the following:
Instance variables
Constructors
Accessor and mutator methods
o Suitable toString() methods
program.txt
73
Hopper 2003 555 Kangaroo 2
Kitty-1 2009 44 Cat 4
Spotty 2005 333 Dog 4
Johnny 2008 111 Cat 4
Danny 2015 433 Dog 4
Striper 2011 432 Skunk 4
Edward 1995 630 Horse 4
Casper 1998 88 Snake Cold-Blooded
Bootsy 2005 987 Horse 4
Ryanne 2014 21 Fish Cold-Blooded
Austin 2015 1500 Monkey 2
William 2009 113 Cat 4
Marya 2013 500 Dog 4
Willy 2012 250 Snake Cold-Blooded
John34 2014 300 Cat 4
Sammy 2014 400 Tiger 4
Annie 2011 20 Bird Warm-Blooded
Sarah 2011 900 Horse 4
Robert 2011 30 Bird Warm-Blooded
Ralphy 2013 50 Chicken
Warm-Blooded
Grants 2013 150 Duck Warm-Blooded
Willy 2012 250 Snake Cold-Blooded
Green 2011 800 Horse 4
Claudia 2014 20 Squid Cold-Blooded
Dukely 2014 10 Fish Cold-Blooded
Hopper2 2003 575 Kangaroo 2
kitty2 2009 64 Cat 4
Spot2 2005 333 Dog 4
Johnny2 2008 111 Cat 4
Danly 2015 433 Dog 4
Striper2 2011 732 Skunk 4
Edward2 1995 630 Horse 4
casper2 1998 188 Snake Cold-Blooded
Boots2 2005 487 Horse 4
Ryan2 2014 110 Fish Cold-Blooded
Austin2 2015 2500 Monkey 2
William2 2009 213 Cat 4
Mary2 2013 520 Dog 4
Willy2 2012 250 Snake Cold-Blooded
John2 2014 320 Cat 4
Sammy2 2014 410 Tiger 4
Annie2 2011 120 Bird Warm-Blooded
Sarah2 2011 950 Horse 4
Raymond2 2011 130 Bird Warm-Blooded
Raymond2 2013 250 Chicken Warm-Blooded
Grant2 2013 350 Duck Warm-Blooded
Willy2 2012 350 Snake Cold-Blooded
Green2 2011 600 Horse 4
Claudia2 2014 10 Squid Cold-Blooded
Hopper3 2003 575 Kangaroo 2
kitty3 2009 64 Cat 4
Spot3 2005 333 Dog 4
Johnny3 2008 111 Cat 4
Dan3 2015 433 Dog 4
Striper3 2011 732 Skunk 4
Edward3 1995 630 Horse 4
casper3 1998 188 Snake Cold-Blooded
Boots3 2005 487 Horse 4
Ryan3 2014 110 Fish Cold-Blooded
Austin3 2015 2530 Monkey 2
William3 2009 213 Cat 4
Mary3 2013 520 Dog 4
Willy3 2012 250 Snake Cold-Blooded
John3 2014 320 Cat 4
Sammy3 2014 410 Tiger 4
Annie3 2011 120 Bird Warm-Blooded
Sarah3 2011 950 Horse 4
Ray3 2011 130 Bird Warm-Blooded
Ray3 2013 250 Chicken Warm-Blooded
Grant3 2013 350 Duck Warm-Blooded
Willy3 2012 350 Snake Cold-Blooded
Green3 2011 600 Horse 4
Claudia3 2014 15 Squid Cold-Blooded

Sample Output: Owner Year Balance Species # Legs / Blood-Type Cold-Blooded Cold-Blooded Cold-Blooded Warm-Blooded Cold-Blooded Cold-Blooded Warm-Blooded 4 Warm-Blooded 2014 Claudia2 2014 Claudia3 2014 2011 2014 2014 2011 2009 2013 2009 2009 1998 2014 2014 2008 2008 2008 2009 2011 2011 Squid Annie Claudia Ryanne Robert Kitty-1 Chicken kitty2 kitty3 Casper Cold-Blooded Cold-Blooded Cold-Blooded 4 Snake 110 110 113 120 120 4 4 Warm-Blooded Warm-Blooded William Annie3 130 130 150 188 188 213 213 250 250 250 250 250 250 300 Warm-Blooded Warm-Blooded Warm-Blooded Cold-Blooded Cold-Blooded Raymond2 2011 2011 2013 1998 1998 William2 2009 William3 2009 2012 2012 2012 Raymond2 2013 2012 2013 2014 2914 Grants casper2 casper3 Snake Snake Willy willy Willy2 Cold-Blooded Cold-Blooded Cold-Blooded Warm-Blooded Cold-Blooded Warm-Blooded Snake Snake Chicken Willy3 Chicken John34
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
