public class Person { // person name protected String name; // defualt constructor public Person() { name
Question:
public class Person
{
// person name
protected String name;
// defualt constructor
public Person()
{
name ="No Name Yet";
}
// 1st argument constructors
public Person(String initialName)
{
name = initialName;
}
//Sets new name
public void setName (String newName)
{
name = newName;
}
//Returns person name
public String getName()
{
return name;
}
// inputs name to console
public void writeOutput()
{
System.out.println("Name : " + name);
}
//returns true in names are the same if not false
public boolean hasSameName(Person otherPerson)
{
return
this.name.equalsIgnoreCase(otherPerson.name);
}
}
// employee
public class Employee extends Person
{
//data members
private double annualSalary;
private int hiredYear;
private String ID;
// constructor with parameters
public Employee(String initialName, double initialSalary, int joinedYear, String id)
{
super(initialName);
annualSalary = initialSalary;
hiredYear = joinedYear;
ID = id;
}
//sets annual salary
public void setAnnualSalary(double newSalary)
{
annualSalary = newSalary;
}
//sets hired year
public void sethiredYear(int year)
{
hiredYear = year;
}
//sets employee id
public void setID(String newID)
{
ID =newID;
}
//returns annual salary
public double getAnnualSalary()
{
return annualSalary;
}
//returns hired year
public int getHiredYear()
{
return hiredYear;
}
// returns employee id
public String getID()
{
return ID;
}
public boolean equals(Employee otherEmployee)
{
if (name.equals(otherEmployee.name))
if (annualSalary == otherEmployee.annualSalary)
if(hiredYear == otherEmployee.hiredYear)
if(ID == otherEmployee.ID)
return true;
return false;
}
//prints the employee name salary hired yr and id
public void display()
{
System.out.println("Employee Name: " + name);
System.out.println("Employee Annual Salary: " + annualSalary);
System.out.println("Employee Hired Year: " + hiredYear);
System.out.println("Employee ID: " + ID);
System.out.println();
}
}
--------------------------------------------------------------------------------------------------------------------------------
public class TestEmployee
{
public static void main (String[] args)
{
// employee objects
Employee e1 = new Employee("John", 50000, 2004, "A101");
e1.display();
}
}
______________________________________________________________________
instead of inputing the data i want to beable to have the user input it all would like someone to help me with the coding to allow the
user to do so
Organizational Behavior Science The Real World and You
ISBN: 978-1111825867
8th edition
Authors: Debra L. Nelson, James Campbell Quick