Question
Create the following classes: Pet and RunSystem Class Pet Has attributes of: PetName String; default value not assigned. PetType String; default value not assigned. PetID
Create the following classes: Pet and RunSystem
Class Pet
Has attributes of:
PetName String; default value not assigned.
PetType String; default value not assigned.
PetID String; default value ;
Every object of type pet must have all three attributes.
Create the necessary get and set methods.
Class RunSystem (main)
Create an array of type Pet. Preferable a 2D array. Allow for 5 entries.
Create any other variables needed.
Start an infinite loop.
Ask the user what they want to do:
- Add a Pet
- Delete a Pet
- Update a Pets name
- Display a list of all pets: name, type and ID
If they choose number 1 then ask for the pet name and type. Generate the next pet id. Create an object of type pet and put it in the array.
If they choose number 2, then ask for the pet id. Search the array for a matching id and delete the pet object.
If they choose number 3, then ask for the old name and the new name. Ask for the pet id and then update the record. Notify if the record is not found.
If they choose number 4, list all the pets by ID, name and type.
Note- to delete a pet, since we are using an array, you will have to create null values for the pet to be deleted. You can set the String values to or null.
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