Question: Help needed with creating 2 class objects - Java programming Class Design: Person - create Name - private instance variable with only private setter -

Help needed with creating 2 class objects - Java programming

Class Design: Person - create Name - private instance variable with only private setter - create Friends - private instance array with neither getter nor setter Constructor - Take in as argument the name of the person (enforce invariants) - Initialize the array of friends to have at most 5 friends if you havent done so already

- .equals() Override compare another instance of a Person to determine whether its the same person or not (what do you compare? How?). - .toString() Override return a String representation of this Person (what do you return?)

- Add Friend take in as argument a Person instance. Some invariants: Cant add self as friend Dont add the same friend more than once. Hint: Use the .equals() method for Person Error checking: Handle the scenario if Add Friend is called when the array is full what should happen

- Add Friend overload take in as argument a name and create a Person object to add to the array of Friends. Enforce invariants.

- Remove Friend allow removing a friend enforce invariants - List Friends print out a list of friends (how is this different than having a getter for Friends?) - Automatically-growing array (zero bonus points if you use ArrayList)

- Enforce bilateral relationships. I.e. Lets say Person A adds Person B as a friend. A bilateral relationship means that when Person A adds Person B as a friend, Person B also adds Person A as a friend. (Aside: What is a realistic model of real life relationships? Unilateral or bilateral?)

Class Design: Driver

The Driver is intended to drive the program and allow you to interact with the Person object.

Positive testing (checking for valid conditions) - Create six instances of a Person - Ensure each person instance has at least one friend - Remove a friend from a person who has several friends - Print out a list of friends from each Person instance

Negative testing (checking for invalid conditions) - Attempt to create a Person with invalid name (e.g. empty string) - Attempt to add a Persons instance (self) to be its own friend - Attempt to add a friend that has already been added - Attempt to remove a friend who has already been removed previously

Boundary testing - Remove a friend from a person who has one friend - Attempt to add a friend to a Person whose friend list is full - Print the list of friends from a Person whose friend list is full

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!