Question: n this lab you will modify the Person class so birthDate now contains a reference to a Date object. You will then modify the Java

n this lab you will modify the Person class so birthDate now contains a reference to a Date object. You will then modify the Java program that declares, views, and edits an array of person objects, so it uses the new Date object properly. The program will then provide the user with a menu that lets them view all the names of the people, view a specific person, edit a specific persons data, or exit the program.

n this lab you will modify the Person class so birthDate nowcontains a reference to a Date object. You will then modify theJava program that declares, views, and edits an array of person objects,so it uses the new Date object properly. The program will thenprovide the user with a menu that lets them view all thenames of the people, view a specific person, edit a specific persons

Class Relationships: Composition LAB In this lab you will modify the Person class so birthDate now contains a reference to a Date object. You will then modify the Java program that declares, views, and edits an array of person objects, so it uses the new Date object properly. The program will then provide the user with a menu that lets them view all the names of the people, view a specific person, edit a specific person's data, or exit the program. Step 1 Create a Date class. Here's the associated UML diagram for your reference: + setYear(int year) : void + getDay() : int + getMonth() : int + getYear() : int + toString(): String setMonth should ensure a month between 1 and 12. setDay should validate day based on month and leap year. int]] days ={0,31,28,31,30,31,30,31,31,30,31,30,31}; if ( month ==2&& day ==29&&( year %400==0 ( year %4==0 \& \& year %100!=0))){ //day is valid 3 else if( day days[month] ). // day is not valid default to 1 } else\{ //day is valid } Modify the person class to use your Date class to store birthDate. Here is the UML diagram for the modified Person class. Note the changes to the birthDate related properties and methods. + setLastName(String lastName) : void + setFirstName(String firstName) : void + setMiddlelnit(char middlelnit) : void + setBirthDate(Date birthDate) : void + toString() : String + displayFormattedDate(): String Step 3 Modify PersonProgram. The first change will involve creating the person objects. Now you will have to pass the Person constructor a new instance of your Date object, like this: people = new Person[5]; people[0] = new Person("John", "Smith", 'T', new Date (9,23,1980)); Change the date edit functionality so it asks for month, day and year separately,(i.e. you the user is prompted for, and enters day, month year in sequence) HINT: Your program can pass these values to the constructor of a new Date object, and pass the Date object to the setter of the Person object. Add some error checking that does the following: - Provides an error message if an invalid menu option is selected and re-displays the menu - Provides an error message if a person object is requested outside the bounds of the array and re-requests the input. - Use a method that accepts a menu prompt, a lower bound, and an upper bound. It only returns values between the bounds

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!