Reminder: we check for cheating (via copying or reuse of code from texts or from lecture), and all students involved with get a grade of zero for this homework.
(70 points) Write a program that allows the user to build and query a list of people's birthdays.
Design sketch. Write the following:
class Date contains three int values: month, day, year. Define a constructor that takes parameters to initialize these three variables. You may make the data members public if you like, or you may want to make them private and define get and set methods for each variable.
class Name contains a person's first name and last name both of type String. You may make the data members public, or make them private and define get and set methods for each variable.
class Birthday contains a person's name (of type Name) and their birthday (of type Date).
The BirthdayList class is implemented as unordered linked-list of Birthday objects. (That means it will have one member variable - perhaps called head.) Define the following methods on a BirthdayList:
insert a named person with a specified birthday.
findByName (and return the Birthday object for) a person given a last name.
birthdaysInMonth take an int representing a month of the year and returns a String of the names of all the people born in that month.
remove a person with a specified last name.
toString (for printing the whole BirthdayList) in the following format (order doesn't matter)
Name1 born on Date1
Name2 born on Date2
...
NameN born on DateN
class ListNode will be the low-level linked list representation for implementing the birthday list. Define it as a local class inside BirthdayList. You may copy and use the one I gave in lecture.
Write a BirthdayManager class that contains static methods for main, presentMenu, getChoice, and evaluateCommand, similar to the first homework. Also, write and use the following two static methods, which first print the specified prompt, then read and return the appropriate value from System.in:
int getInteger(String prompt);
String getString(String prompt);
main will create a local BirthdayList called birthdays, and all user actions will operate on this BirthdayList. Here are the user commands you must handle:
Add Person inserts the user-entered name, year, month, and day into birthdays using the insert method. (Use getString and getInteger with appropriate prompts to get the name, year, month, and day from the user.)
Find by Name gets a name from the user (via getString) and calls the findByName method. If the name requested is not in the list, an appropriate message should be displayed.
Find by Month reads a month from the user (via getInteger) and calls the birthdaysInMonth method. It then displays the names with birthdates of all the people born in that month in the same format given above for toString.
Remove Person calls removePerson with a String parameter. If the person is not in the list, it should silently do nothing.
If Print List is selected, people is printed to System.out using the format specified above for toString().
If anything else is entered, a warning like "invalid entry" is printed to System.out, and the menu is reprinted.
If Quit Program is selected, the program prints "Bye" then terminates.
The program continues to loop until the user selects Quit Program from the menu.
(30 points) Modify your program above to use an implementation of UnorderedArrayList. I recommend you get one program to work completely, then copy it and change the implementation of Birthdaylist to be an UnorderedArrayList.