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.
Also attach a UML diagram that includes all the classes involved
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started