Question

In: Computer Science

Project 8-2: Person Manager Create an application that lets you enter a new customer or a...

Project 8-2: Person Manager

Create an application that lets you enter a new customer or a new employee.

Create a class named Person with these constructors and methods:

public Person(String first, String last)

public String getFirstName()

public void setFirstName(String first)

public String getLastName()

public void setLastName()

The Person class should override the toString() method so it returns the first name and last name in this format:

Name: Frank Jones

Create a class named Customer that inherits the Person class and contains these constructors and methods:

public Customer(String first, String last, String number)

public String getCustomerNumber()

public void setCustomerNumber(String number)

The Customer class should override the toString() method so it returns the value returned by the toString() method of the Person class appended with the customer number, like this:

Name: Frank Jones
Customer Number: J54128

Create a class named Employee that inherits the Person class and contains these constructors and methods:

public Employee(String first, String last, String ssn)

public String getSsn()

public void setSsn(String ssn)

The getSsn() method should return a masked version of the social security number that only reveals the last four numbers.

The Employee class should override the toString() method so it returns the value returned by the toString() method of the Person class appended with the social security number, like this:

Name: Frank Jones
SSN: xxx-xx-1111

Solutions

Expert Solution

class Person {
   private String firstName;
   private String lastName;

   public Person(String aFirstName, String aLastName) {
       super();
       firstName = aFirstName;
       lastName = aLastName;
   }

   public String getFirstName() {
       return firstName;
   }

   public void setFirstName(String aFirstName) {
       firstName = aFirstName;
   }

   public String getLastName() {
       return lastName;
   }

   public void setLastName(String aLastName) {
       lastName = aLastName;
   }

   @Override
   public String toString() {
       return "Name : " +firstName + " " +lastName;
   }

}

class Customer extends Person {
   private String customerNumber;
   // constructor initialize the values using super constructor
   public Customer(String aFirstName, String aLastName, String aCustomerNumber) {
       super(aFirstName, aLastName);
       customerNumber = aCustomerNumber;
   }

   public String getCustomerNumber() {
       return customerNumber;
   }

   public void setCustomerNumber(String aCustomerNumber) {
       customerNumber = aCustomerNumber;
   }
   //to string returns name and customer number
   @Override
   public String toString() {
       return super.toString() + "\nCustomerNumber: " + customerNumber;
   }

}

class Employee extends Person {
   private String ssn;
// constructor initialize the values using super constructor
   public Employee(String aFirstName, String aLastName, String aSs) {
       super(aFirstName, aLastName);
       ssn = aSs;
   }

   public String getSsn() {
       return ssn;
   }

   public void setSsn(String aSs) {
       ssn = aSs;
   }

   @Override
   //to string returns name and ssn
   public String toString() {
       return super.toString() + "\nSSN: " + ssn;
   }

}

public class TestPerson {
   public static void main(String[] args) {
       Person p1 = new Customer("Frank", "Jones", "J54128");
       Person p2 = new Employee("Frank", "Jones", "XXXX-XXXX-1111");
       System.out.println(p1);
       System.out.println(p2);

   }
}

Note : If you like my answer please rate and help me it is very Imp for me


Related Solutions

Create a JavaFX application that lets the user enter the food charge for a meal at...
Create a JavaFX application that lets the user enter the food charge for a meal at a restaurant. For example, if $20 is entered as a food charge for a meal then $3.6 should be displayed for the tip, $1.4 should be displayed for sales tax, and $25 should be displayed as a total of all three amounts. Modification 1: create a text box (not a pop up) for the user to enter a percent tip (don't just hardcode it...
Program on Visual Basic, VBA Create an application that lets the user enter a number of...
Program on Visual Basic, VBA Create an application that lets the user enter a number of seconds and produces output according to the following criteria: There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or...
Time Calculator ( PROGRAM VBA EXCEL) Create a application that lets the user enter a number...
Time Calculator ( PROGRAM VBA EXCEL) Create a application that lets the user enter a number of seconds and produces output according to the following criteria: There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than...
Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
Project 5-3: Guessing Game Create an application that lets a user guess a number between 1...
Project 5-3: Guessing Game Create an application that lets a user guess a number between 1 and 100. Console Welcome to the Guess the Number Game ++++++++++++++++++++++++++++++++++++ I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 You got it in 1 tries. Great work! You are a mathematical wizard. Try again? (y/n): y I'm thinking of a number from 1 to 100. Try to guess it. Enter number: 50 Way too high! Guess...
Lets say you are a person who wants to persue a career in project management but...
Lets say you are a person who wants to persue a career in project management but you are not sure if that's really what you want and you are given and chance to meet with a project manager. Please compile 10 questions to use in an interview with a project manager. These questions must give a clear understanding whether you want to pursue this project management career or not
C# Create an application that asks the user to enter their new password. The password must...
C# Create an application that asks the user to enter their new password. The password must be at least 6 characters long. Develop a custom exception handling case that checks for the password length. (hint: use " .Length " built-in method). If the new password is less than 6 characters long the custom exception should output an error message.
3. Identify the following as master data or transaction data Create New Customer Create Contact Person...
3. Identify the following as master data or transaction data Create New Customer Create Contact Person for Customer Create BP relationship Create Customer Inquiry Create Customer Quotation Create Sales Order Referencing a Quotation Check Stock Status Display Sales Order Start Delivery Process Check Stock Status Pick Materials on Delivery Note Post Goods Issue Check Stock Status Create Invoice for Customer Display Billing Document and Customer Invoice Post Receipt of Customer Payment Review Document Flow
Time Calculator Create a C++ program that lets the user enter a number of seconds and...
Time Calculator Create a C++ program that lets the user enter a number of seconds and produces output according to the following criteria: • There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. • There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or...
Create a C# application for Cricket Team that allows you to enter data for player of...
Create a C# application for Cricket Team that allows you to enter data for player of Cricket Team and saves the data to a file named Players.txt. Create a Player class that contains fields for of participant's first name, last name, age, salary and position (wicketkeeper, bawler, striker, midwicket), and To String() method. The fields of records in the file are separated with semicolon (. Expecting sentinel value for ending the process of writing to file is *. E.g. of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT