Question: Java language. Create 6 classes: Main) Dog) Pet) Rock) StringUtil) (to perform the stringbuilder class). Invoice) (create an arraylist to store the objects from the

MACI90 Project 1/30/2020 Due: 2/6/2020 Project goals: Use inheritance, polymorphism, separate files, exception handling. Arraylist Generics and Collections, and the use of stringBuilder class for building reports to write the definition for the classes Define a Pet class that stores the pet's name, age, and weight. Add appropriate constructors, accessor, and mutator methods. Also define a method named getLifespan (The length of time for which a person or animal lives or a thing function) that returns a string with the value "Unknown lifespan." Next, define a Dog class that is derived from Pet. The Dog class should have a private member variable named breed that stores the breed of the dog. Add mutator and accessor methods for the breed variable and appropriate constructors. Redefine the getLifespan method to return "approximately 7 years" if the dog's weight is over 100 pounds and "approximately 13 years" if the dog's weight is under 100 pounds. Schoositehaus Next, define a Rock class that is derived from Pet. Redefine the getLifespan method to return "thousands of years." Note: Finally, write a test program that creates instances of pet rocks and pet dogs that exercises the inherited and redefine methods
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
