Question: The Person Class This class should go in a package called people. A person has first name last name email address Address and one or

The Person Class

This class should go in a package called people.

A person has

first name

last name

email address

Address

and one or more PhoneNumbers (NOTE: A person can have any number of phone numbers, so design this class accordingly)

Override the toString() and equals() methods to print a Person and to check the equality of a Person. Two Person objects are equal if they have the same first name, last name, email address, Address, and same list of phone numbers (all phone numbers in the list must be equal).

NOTE: For the sake of simplicity, you may assume that the PhoneNumber lists of two people who are the same, will already have the phone numbers in the same order. You do not have to worry about sorting the PhoneNumber lists, but you do need to figure out how to compare both lists to determine if the numbers in each list are the same.

The Address Class

This class should go in a package called contact_information.

An address has:

street number

optional apartment number

NOTE: This field should have a value of -9999 if the Address does not refer to an apartment.

street name

city

state

zip code

NOTE: We will simplify this field and only accept the 5 digit zip code format, NOT the zip+4 (12345-1234) format.

Override the toString() and equals() methods to print an Address and to check the equality of an Address. Two Address objects are equal if all data fields are exactly the same.

The PhoneNumber Class

This class should go in a package called contact_information.

A phone number has:

type (cell phone, home phone, business, etc...)

an area code

a prefix

a suffix

Example: 323-343-1234, 323 is the area code, 343 is the prefix, 1234 is the suffix. NOTE: You must store the parts of the phone number separately.

Override the toString() and equals() methods to print a PhoneNumber and to check the equality of a PhoneNumber. Two PhoneNumber objects are equal if all data fields have the same values.

The Employee Class

This class should go in a package called people.

Employee is a subclass of Person

An employee has:

an office location (i.e. E&T-220),

a salary

Override the toString() and equals() methods to print an Employee and to check the equality of an Employee. Two Employee objects are equal if all data fields are exactly the same.

The Faculty Class

This class should go in a package called people.

Faculty is a subclass of Employee

a faculty has:

office hours

a rank (full time or part time are the only valid ranks)

Override the toString() and equals() methods to print a Faculty and to check the equality of a Faculty. Two Faculty objects are equal if all data fields are exactly the same.

The Staff Class

This class should go in a package called people.

Staff is a subclass of Employee.

a staff has:

a job title (Head Librarian would be an example of a job title at a university library)

Override the toString() and equals() methods to print a Staff and to check the equality of a Staff. Two Staff objects are equal if all data fields are exactly the same

The Student Class

This class should go in a package called people.

Student is a subclass of Person

a student has

a class standing (freshman, sophomore, junior, senior, or graduate)

Override the toString() and equals() methods to print a Student and to check the equality of a Student. Two Student objects are equal if all data fields are exactly the same

The Database Class

(Note: Follow this class exactly as it is described here)

This class should go in a package called university_database.

Database is a subclass of ArrayList. Yes this is possible. You will need to play around with this to figure out how to make your list work.

A default constructor to initialize an empty Database.

add the following methods:printDatabase:

this method has two versions.

the first version displays all of the information of the students, faculty, and staff stored in the database.

the second version takes a String as as a parameter indicating the type of person you what to see.

Possible arguments are "Employee", "Staff", "Student", "Faculty". NOTE: This method should be case-insensitive..

getNumberOfPeople, getNumberOfStudents, getNumberOfEmployees, getNumberOfStaff, getNumberOfFaculty:

these are five different methods which each return the number of people, students, employees, staff, or faculty respectively.

getNumberOfStudentsByClassStanding:

this method should take the class standing as a String parameter ("freshman", "sophomore", etc.) and return the number of students there are with that class standing.

displayEmployeesGreaterThanSalary:

this method takes a salary as a parameter and displays all employees with a salary greater than the value given.

displayEmployeesEqualToSalary

this method takes a salary as a parameter and displays all employees with a salary equal to the value given.

displayEmployeesLessThanSalary

this method takes a salary as a parameter and displays all employees with a salary less than the value given.

COMPLETED

--------------------------------------------------------------

Menu System:

Add a menu system to your project with options to Add a new Person to the Database, Remove a Person from the Database, and Find a person in the Database.

This should take into account type of people (Employee, Student, Faculty, etc.)

Your menu system should use Exception Handling to verify that all user input values are the correct data type.

HINT: See the InputMismatchDemo.java example from this week's lecture.

HINT: You may want to build the menu system in its own class.

HINT: You may need to add some new methods to your Database class.

An addPerson method which can take a created Person object and add it to the Database.

A removePerson method which can take a person's full name, search through the database and removes the person. If the name matches more than one person, display all matches and allow the user to choose which one to remove.

A findPerson method which can take a person's full name, search through the database and return the person object you are searching for.

NOTE: This will be more work than it sounds so think it through very carefully. You must be able to allow the user to enter all information necessary to create a new Person for the database.

Be creative and try to make your system as modular as possible.

COMPLETED

-----------------------------------------------

Custom Exception:

Create a custom exception class called PhoneNumberFormatException.

This should be a checked exception.

This exception should have a String data field to store an entered phone number (for purposes of displaying the phone number in an error message).

HINT: See the InvalidRadiusException.java example.

During the creation of a new person to add to the database, one thing you will need to ask for is the list of phone numbers. The user should enter a phone number in the form "555-555-5555", a string with the parts of the number separated by a hyphen. If the string entered does not follow the correct format, you should throw a PhoneNumberFormatException.

CSV File Format:

The general format of an entry in the .csv file for a Person looks like the following:

PersonType,FirstName,LastName,Street #,Optional Apt. #,Street Name,City,State,AreaCode,email,additional information related to PersonType Phone,Type,AreaCode,Prefix,Suffix Phone,Type,AreaCode,Prefix,Suffix ... Additional phone numbers may follow 

An example .csv file is given in the following. NOTE: You may NOT use this information.

Student,Jack,Smith,117,Sunshine Dr.,Los Angeles,CA,90012,jsmith@school.edu,freshman Phone,Cell,555-555-5555 Phone,Home,777-777-7777 Faculty,Jack,Smith,117,Apt. 21,Sunshine Dr.,Los Angeles,CA,90012,jsmith@school.edu,E&T-310,40000,M/W 1-2 T/TH 3-4,Full Time Phone,Cell,555-555-5555 Phone,Home,777-777-7777 Phone,Work,888-888-8888 Staff,Jack,Smith,117,Apt. 15,Sunshine Dr.,Los Angeles,CA,90012,jsmith@school.edu,E&T-310,30000,Computer Science Administrative Assistant Phone,Cell,555-555-5555

Things to Notice:

There are no spaces between the commas, but there could be spaces in the values between the commas (ex. the street name, city, etc).

There are no spaces between lines.

Each line begins with the type of object the information in that line belongs to.

This will help you to figure out if you need to create a Student, Faculty, Staff, etc.

This will also help you to figure out if the line you just read is Person information, or a phone number belonging to the previous person.

After a line that lists a Person's information, there are any number of lines that list the phone number(s) of the previous Person. Remember that a Person may have any number of phone numbers.

You will also need to parse the phone number into its area code, prefix, and suffix. (Perhaps a second use of the .split() function )

Notice how the first Student does not have an apartment number, but the Faculty and Staff do. You will need to take this into account when parsing a csv file. (This doesn't mean a Student will never have an Apartment number or that a Faculty or Staff always do. Just keep in mind each Person in the .csv file may or may not have an apartment number.)

HINT: You can read the information for a Person, create that type of Person object, and then save it to your Database. When you start reading phone numbers you know that they should belong to the last person added to your Database and it should be easy for you to figure out how to find the last person in the Database to add their phone numbers.

Create Your CSV File:

Take your test data from your University Database assignment and format it in a .csv file following the format given above.

Be sure to have a different number of phone numbers for different people for testing purposes.

Be sure to handle the apartment number vs. not having an apartment number correctly.

Please delete (or comment out) the lines of code that dealt with creating the prepopulated People. Since this will be handled by your DatabaseIO class, it does not make sense to leave this code lying around.

DatabaseFileIO Class:

This class should have at least one method which reads a database .csv file and returns a Database object populated with the data from the .csv file.

This class should have at least one method which writes a Database object to a .txt file. This method should be able to print the entire Database to a .txt file instead of to the console.

You may add whatever other private methods you feel are necessary to help complete the above two methods.

Combining with Previous Assignment:

Add an option to your menu system to choose a .csv file to load the data into your program.

Please design this option to use JFileChooser (preferred method), or ask the user for the name of the .csv file.

If you do not use JFileChooser, you will need to check to see if the file exists first.

Add an option to your menu system to print the Database to a .txt file.

Please write the output to a file called database_output.txt

If your DatabaseFileIO class is designed correctly, it should be able to build an instance of your Database class, containing all of the data from the .csv file, which you can then use with the previously implemented menu options.

INCOMPLETE

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!