Texts: USE JAVA JOPTIONPANE
In this lab, you will create a Pet class. The instance variables should include name (String) and species (String).
We also want a way to represent the Pet's owner, which is a Person. So you will also create a Person class with an instance variable of name (String).
What kind of relationship should we have between a Pet and an Owner? A pet has an owner, so this is a has-a relationship, but is it aggregation or composition?
Owners and pets both exist as entities in the world. One is not part of the other. So this is aggregation!
So let's add an instance variable to the Pet class called owner, that will contain a reference to a Person. Make sure your Pet class contains a toString method that returns a string of the Pet's name, species, and owner's name.
Create a small implementation class that creates two Persons (Lee and Kim) and three Pets: a dog Fido (owned by Lee), a dog Rover (owned by Kim), and a cat Whiskers (owned by Lee), and then displays the information about each Pet using the toString method of Pet.
Notes:
1. As usual for labs, no validation is needed.
2. It is not necessary to use arrays in your implementation class, but you can if you want to.
3. You will probably find it easiest to add the owners as part of a Pet constructor, but it's not required. You can use a setOwner mutator if you prefer.
4. Make sure your owner variable is referring to the existing person objects for Lee and Kim, rather than creating new Person objects for each Pet's owner. (That would be composition!)