Phase 1

Overview: For this program you are tasked with writing a program which stores database of the information for Students, Faculty, and Staff at a local university. The program will make use of inheritance and polymorphism. Make sure this program works, we might be coming back to this assignment to add to it later on.

The Person Class

  • A person has a first name, last name, email address, Address, and 1 or more PhoneNumbers
  • NOTE: A person can have any number of phone numbers.

The Address Class

  • An address has a street number, optional apartment number street name, city, state, zip code.

The PhoneNumber Class

  • A phone number has a type (cell phone, home phone, business, etc...), an area code, prefix, and suffix Example: 323-343-1234, 323 is the area code, 343 is the prefix, 1234 is the suffix.

The Employee Class

  • Employee is a subclass of Person
  • An employee has an office location (i.e. E&T-220), and a salary

The Faculty Class

  • Faculty is a subclass of Employee
  • a faculty has office hours, and a rank (full time or part time are the only valid ranks)

The Staff Class

  • 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)

The Student Class

  • Student is a subclass of Person
  • a student has a class standing (freshman, sophomore, junior, senior, or graduate)

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

  • the only data field that you are allowed to have is an ArrayList of Person objects.
  • at least one constructor which takes an ArrayList of Person objects.
  • add any necessary getters and setters
  • add the following methods:
    • printDatabase
    • parameters: none
    • return type: void
    • this method should display all the information of the students, faculty, and staff stored in the database.
    • printDataBase
    • this is an overloaded method based on the previous one
    • parameters: String
    • return type: void
    • this method takes a string parameter type, and displays only the type of person you want to see i.e. only displays all employees, staff, faculty, or students.
    • getNumberOfPeople, getNumberOfStudents, getNumberOfEmployees, getNumberOfStaff, getNumberOfFaculty
    • these are five different methods
    • parameters: none of the methods take any parameters
    • return type: all of the methods should return an int
    • these methods should return the number of people, students, employees, staff, or faculty respectively.
    • getNumberOfStudentsByClassStanding
    • parameters: String
    • return type: int
    • this method should take the class standing of student as a string parameter "freshman", "sophomore", etc, and return the number of students there are with that class standing
    • displayEmployeesGreaterThanSalary
    • parameters: double
    • return type: void
    • this method takes salary as a parameter and displays all employees with a salary greater than the value given.
    • displayEmployeesEqualToSalary
    • parameters: double
    • return type: void
    • this method takes salary as a parameter and displays all employees with a salary equal to the value given.
    • displayEmployeesLessThanSalary
    • parameters: double
    • return type: void
    • this method takes salary as a parameter and displays all employees with a salary less than the value given.

NOTE: For the most part you will be designing the classes yourself. It should be understood that your classes should provide any necessary constructors, getters/setters, toString(), and any other methods you feel are necessary to make the class work. I have given basic guidelines which must be followed at the very least. For any primitive type data fields, consider and choose the best type based on the type of information you are storing.

NOTE: Pay careful attention to which classes are super classes, which classes are sub classes, and which classes are neither a super class or sub class of another. If you do not get the inheritance correct, you will have a very difficult time with this program. It may help to draw a diagram of how all of the classes interconnect.

Putting it all together:

Your program must demonstrate that everything is working correctly. Create test data for some students, faculty, and staff. You should display all the output generated from each of the methods in the Database class:

  • display the information of all people in the database
  • display the information of all employees in the database
  • display the information of all faculty in the database
  • display the information of all staff in the database
  • display the information of all students in the database
  • display the number of people
  • display the number of employees
  • display the number of faculty
  • display the number of staff
  • display the number of students
  • display the number of freshman
  • display the number of sophomores
  • display the number of juniors
  • display the number of seniors
  • display the number of graduates
  • display the information for all employees with a salary greater than 30000
  • display the information for all employees with a salary equal to 30000
  • display the information for all employees with a salary less than 30000

Grading: All of the information displayed about an object should be clearly identified and formatted to look nice on the console (see example output below). If I have a hard time interpreting the output from your program, deductions will be made. I will also be testing your programs with input that I have generated. I will supply an ArrayList of Person objects to the constructor of your Database class, and I will run your program using my data.

Example formatted output for a Student (Similar formats should be used for other types of people):

Name: John Smith
Email: jsmith1@university.edu
Address: 1313 California Dr. Los Angeles, CA, 90011
Phone Number(s):
Home: (323) 343-7777
Cell: (323) 998-5555
Class Standing: Junior

Phase 2

Overview: For this program you will be adding a new class to last week's project. This class will provide a way to read data from a file and populate an ArrayList of Person objects. Use the lecture from this week to build a class which uses Text I/O to read text from a .csv (comma separated value) file. The text file will have values in the following format:

ObjectType,first name,last name, …. all the rest of the information
Phone,type,area code,prefix,suffix

A person could have any number of phone numbers listed after their information. There are no spaces between the entries, and no spaces before or after a comma.

I am leaving this assignment vague because I want you to design the class in your own way. The only requirement is that the class must read a file (ask the user for the name of the file) and return an ArrayList< Person>, (which you can use with your Database class).

Example File (Note: You should make your own test data or use the test data from the previous week.)

Student,Jack,Smith,117,-1,Sunshine Dr.,Los Angeles,CA,90012,jsmith@school.edu,freshman
Phone,Cell,555,555,5555
Phone,Home,777,777,7777
Faculty,Jack,Smith,117,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,15,Sunshine Dr.,Los Angeles,CA,90012,jsmith@school.edu,E&T-310, 30000,Computer Science Administrative Assistant
Phone,Cell,555,555,5555

The indented lines should be on the previous line, I just had to move it down due to word wrapping.

Note the use of -1 here. -1 at that position signifies that the person does not have an apartment number. Any other positive value would be their apartment number.

HINT: You will want to read through the API for the Scanner class as well as the API for the String class. Also, you may need to use the parsing methods from the Numeric Wrapper Classes, so you should look at the API's for those as well. Also, the split() method of the String class may be very useful here.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.