Question
Write a complete program (Java) to keep track of people and their possible marriages. People have a name (you decide the format), age, and sex.
Write a complete program (Java) to keep track of people and their possible marriages. People have a name (you decide the format), age, and sex. Two people over the age of 18 may get married if neither one is married currently. Marriages can be annulled or ended any time after which people can marry again. Decide what classes you need first. It is helpful to ask what are the key nouns in the system requirements?
Details and suggestions:
a. Define a good and complete class for Person. Add useful methods (possibly isMarried, canMarry, age,). I suggest you store date of birth and calculate the age the person is today.
b. Be able to print out the current list of people in the system.
c. Think about how you want to identify people (full name, last name, person id, pick from list by index, etc.)
d. Allow multiple people to be added by the user
e. Provide some way to keep track of current marriages (some type of collection may be useful)
f. Allow the user to attempt to marry two (already entered) people, test to see if that is allowed, and confirm the result to the user
g. Allow the user to attempt to end an existing marriage. If it makes sense, update the system and confirm the result to the user
h. Be able to print out the current list of marriages (you pick the format)
i. Be sure there is some way to end the program. Before ending print out the list of all people and the current marriages.
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