Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a class that represents a person in a simple way First download the driver

ID: 675314 • Letter: W

Question

Write a class that represents a person in a simple way

First download the driver and put it in your project

DO NOT ALTER THE DRIVER!

Write a class file called SimplePerson that DOES NOT HAVE a main method

Some of the attributes of SimplePerson are

Name

Create the following ConstructorsDefault – sets everything to default values

Name = No name yet

One that has the parameters

Name

Accessors and Mutators for each variable

MAKE SURE THE MUTATORS CHECK FOR VALID VALUES!

Create the following Methods

writeOutput – This prints out “Name: “ and the person’s name

hasSameName – this takes in another SimplePerson object and then returns a true if their names are the same

equals – this should override the base object equals method and should return true if the person’s name is equal.

Write another class that represents an employee

Write a class called Employee that also DOES NOT HAVE a main method

Since an employee IS A person make it so that employee derives from the person

Some of the attributes of an Empolyee are

Annual Salary (assumed to be a decimal value)

Hire date (a string should work)

ID number (assumed to be a whole number)

Create the following constructorsDefault – sets everything to default values

Name = No name yet

Salary = 0

Hire date = Not hired

ID number = 0

One that takes in parameters (in this order)

Name

Salary

Hire Date

ID number

Accessors and Mutators for each variable

MAKE SURE THE MUTATORS CHECK FOR VALID VALUES!

Create the following methods

equals – this should override the object base equals method and it should test whether another employee has the same name, salary, hire date, and id number

writeOutput – Prints out the information about the employee including their nae, salary, hire date, and id number

Example Dialog:

Welcome to the Company Management Software!

What would you like to do?

1. Hire a new employee

2. Look up information on an employee

3. Compare two employees

4. Quit

1

Enter their name

JJ

Enter their hire date

1/1/2011

Enter thier salary

20000

Enter the employee number

1

Name : JJ

Makes 20000.0

Was hired 1/1/2011

ID number is 1

What would you like to do?

1. Hire a new employee

2. Look up information on an employee

3. Compare two employees

4. Quit

1

Enter their name

Bob

Enter their hire date

1/2/2010

Enter thier salary

25000

Enter the employee number

2

Name : Bob

Makes 25000.0

Was hired 1/2/2010

ID number is 2

What would you like to do?

1. Hire a new employee

2. Look up information on an employee

3. Compare two employees

4. Quit

1

Enter their name

JJ

Enter their hire date

1/1/2011

Enter thier salary

20000

Enter the employee number

1

Name : JJ

Makes 20000.0

Was hired 1/1/2011

ID number is 1

What would you like to do?

1. Hire a new employee

2. Look up information on an employee

3. Compare two employees

4. Quit

3

Enter the two indices corresponding to the employees

0

1

These employees are the different!

What would you like to do?

1. Hire a new employee

2. Look up information on an employee

3. Compare two employees

4. Quit

3

Enter the two indices corresponding to the employees

0

2

These employees are the same!

What would you like to do?

1. Hire a new employee

2. Look up information on an employee

3. Compare two employees

4. Quit

2

Enter the employees id number

2

Name : JJ

Makes 20000.0

Was hired 1/1/2011

ID number is 1

What would you like to do?

1. Hire a new employee

2. Look up information on an employee

3. Compare two employees

4. Quit

2

Enter the index number of the employee

1

Name : Bob

Makes 25000.0

Was hired 1/2/2010

ID number is 2

What would you like to do?

1. Hire a new employee

2. Look up information on an employee

3. Compare two employees

4. Quit

4

The Driver Is:

Explanation / Answer

//Employee.java

package chegg;

public class Employee extends SimplePerson{

double annualSalary;

   String hireDate;

   int id;

  

   public Employee() {

       super();

       annualSalary = 0;

       hireDate = "Not hired";

       id=0;

   }

  

   public Employee(String n, double salary, String hireDate, int idNumber) {

       super(n);

       this.annualSalary = salary;

       this.hireDate = hireDate;

       this.id = idNumber;

   }

  

@Override

   public boolean equals(Object obj) {

       // TODO Auto-generated method stub

       Employee e = (Employee)obj;

       if(super.equals(obj)) {

           return (annualSalary == e.getAnnualSalary() && hireDate.equals(e.getHireDate()) && id == e.getId());

       }

      

       return false;

   }

  

@Override

   public void writeOutput() {

       // TODO Auto-generated method stub

       super.writeOutput();

      

       System.out.println("Annual Salary: "+annualSalary);

       System.out.println("Hire Date: "+hireDate);

       System.out.println("ID: "+id);

   }

  

   public double getAnnualSalary() {

       return annualSalary;

   }

   public void setAnnualSalary(double annualSalary) {

       this.annualSalary = annualSalary;

   }

   public String getHireDate() {

       return hireDate;

   }

   public void setHireDate(String hireDate) {

       this.hireDate = hireDate;

   }

   public int getId() {

       return id;

   }

   public void setId(int id) {

       this.id = id;

   }

  

  

}

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

//SimplePerson.java

package chegg;

import java.util.jar.Attributes.Name;

public class SimplePerson {

   private String Name;

   public SimplePerson() {

       Name = " No name yet";

   }

  

   public SimplePerson(String n) {

       Name = n;

   }

  

  

   public String getName() {

       return Name;

   }

   public void setName(String name) {

       Name = name;

   }

  

   public void writeOutput() {

       System.out.println("Name: "+Name);

   }

  

   public boolean hasSameName(SimplePerson n) {

       return Name.equals(n.getName());

   }

  

@Override

   public boolean equals(Object obj) {

       // TODO Auto-generated method stub

       SimplePerson s = (SimplePerson)obj;

       return Name.equals(s.getName());

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote