Question: A pet store would like to implement a system which helps to track all of the different animals it sells in the store. This system
A pet store would like to implement a system which helps to track all of the different animals it sells in the store.
This system will store the necessary care information for each pet as well as important retail information such as how many are in stock and price.
The only pets sold in this store are dogs and fish.
Create a class, Pet, which contains all of the necessary fields and methods that are common to both kinds of pets.
Class: Pet
Fields: numInStock, price
Constructor: one that accepts numInStock and price as parameters, and one with no parameters
Methods: addToStock, sell, accessor methods
Create a subclass for each type of Pet with fields and methods specific to that type of Pet.
Class: Dog
Constructor: accepts birthday and type
Fields: name, birthday, age, likesChildren
Methods: a private method that calculates the age field based on birthday, appropriate accessor methods
Class: Fish
Constructor: accepts freshOrSalt and lifespan
Fields: freshOrSalt, lifespan
Methods: all getter and setter methods
Create a main program to test your objects. You do not actually have to create a POS system for a store, you are just doing a rough test of your methods in each object.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
