CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades | Students

Assignment #6

Work with customer and employee data

Due Date: Monday of Week 3
25 points

This project uses a superclass that defines a person and two subclasses that define customers and employees. The superclass includes an abstract method for displaying the information in the class that is implemented by both subclasses. Each subclass also includes an additional instance variable. The application includes a method that accepts an object of the superclass type. This is a good project for working with inheritance that isn't too difficult.

Console

Operation

  • The application prompts the user to enter a customer or an employee.
  • If the user selects customer, the application asks for name, email, and customer number.
  • If the user selects employee, the application asks for name, email, and social security number.
  • When the user finishes entering data for a customer or employee, the application displays the data that the user entered.

Specifications

  • Create an abstract Person class that stores first name, last name, and email address. This class should provide a no-argument constructor, get and set methods for each piece of data, and it should override the toString method so it returns the first name, last name, and email fields in the format as shown in the console above.
  • In addition, it should contain an abstract method named getDisplayText that returns a string.

  • Create a class named Customer that inherits the Person class. This class should store a customer number, it should provide get and set methods for the customer number, it should provide a no-argument constructor, and it should provide an implementation of the getDisplayText method. The getDisplayText method should return a string that consists of the string returned by the toString method of the Person class appended with the Customer number like shown in the console above.

  • Create a class named Employee that inherits the Person class. This class should store a social security number, it should provide get and set methods for the social security number, it should provide a no-argument constructor, and it should provide an implementation of the getDisplayText method. The getDisplayText method should return a string that consists of the string returned by the toString method of the Person class appended with the Employees social security number like shown in the console above.

  • Create a class named PersonApp that prompts the user as shown in the console output. This class should create the necessary Customer and Employee objects from the data entered by the user, and it should use these objects to display the data to the user. To print the data for an object to the console, this application should use a static method named print that accepts a Person object.

  • Use the Validator class (in the assignment 5) to validate the user's entries.
Include in your program the following comments:
  • Name of program
  • Programmer's name
  • Current Date
  • Computer system and compiler you are using
  • Brief description of the program

Compile and run the Java program.

Take a screen capture by hitting simultaneously the keys Alt and Print Screen (Prt Sc) of the output results (console) and paste it in MS Paint. Save it as a gif file.

When you are ready, upload the java program and the gif file by clicking the link below:

Upload Assignment

I cannot grade if I don't get the files and receive your email.