Question: In Java, create and implement the following four files: 1. A PetAnimals parent class containing type/category (e.g., reptiles, insects, mammals, etc.) and name attributes (e.g.,
In Java, create and implement the following four files: 1. A PetAnimals parent class containing type/category (e.g., reptiles, insects, mammals, etc.) and name attributes (e.g., cats, dogs). 2. PetFood inherits from PetAnimals and adds a price per kilogram attribute. 3. PetMeds inherits from PetAnimals and has a sold attribute (eg tincture, bulk powder, capsule, tablet, etc) . 4. A driver file that will be used to test the three classes mentioned previously.
Each class 1,2,3 should contain the usual constructors (default and parameterized), get (accessor), and set (mutator) methods, as well as a function toString()
To avoid code duplication, child classes should call parent methods wherever feasible.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
