Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please put modifications to this code. Employee.java public class Employee { private String name; private int idNumber; private String department; private String position; public Employee(String

image text in transcribed

Please put modifications to this code.

Employee.java

public class Employee {

private String name;

private int idNumber;

private String department;

private String position;

public Employee(String name, int idNumber, String department, String position) {

this.name = name;

this.idNumber = idNumber;

this.department = department;

this.position = position;

}

public Employee(String name, int idNumber) {

this.name = name;

this.idNumber = idNumber;

this.department = "";

this.position = "";

}

public Employee() {

this.name = "";

this.idNumber = 0;

this.department = "";

this.position = "";

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getIdNumber() {

return idNumber;

}

public void setIdNumber(int idNumber) {

this.idNumber = idNumber;

}

public String getDepartment() {

return department;

}

public void setDepartment(String department) {

this.department = department;

}

public String getPosition() {

return position;

}

public void setPosition(String position) {

this.position = position;

}

@Override

public String toString() {

return "Employee [name=" + name + ", idNumber=" + idNumber + ", department=" + department + ", position="

+ position + "]";

}

} -------------------------------------------------------------------------------------------------------------------------------- EmployeeTest.java public class EmployeeTest {

public static void main(String[] args) {

// TODO Auto-generated method stub

Employee e1 = new Employee("Susan Meyers", 47899, "Accounting","Vice President");

Employee e2 = new Employee("Mark Jones", 39119, "IT", "Programmer");

Employee e3 = new Employee("Joy Rogers", 81774 ,"Manufacturing", "Engineer");

System.out.println(e1);

System.out.println(e2);

System.out.println(e3);

}

}

Modify the Employee class from the previous problem to add overloaded constructors: Ano-arg constructor that assigns empty strings ("") to the name, department, and position fields, and 0 to the idNumber field A constructor that accepts an employee's name and ID number an assigns them to appropriate fields. The department and position fields should be assigned an empty string("") A constructor that accepts the following values as arguments and assigns them to the appropriate fields: employee's name, employee's ID number, department, and position Add a new method "outputEmployeelnfo" to display all employee information on-screen using System.out.println. Use the new constructors to create employees and display their data. The employee data to create: No-arg constructor: Name ID Number Department Position Van Tyler 32532 Accounting Vice President Diana Wells 35258 IT Programmer Kathy Dixonial 87778 Manufacturing Franginier Employee name and ID constructor: Oliver Mills 12579 Accounting Vice President Robert Goodman 86485 IT Programmer Linda Cunningham 58255 Manufacturing Engineer All-fields constructor: Kendra Beck 75956 Accounting Vice President Cathy Mckinney 39858 Programmer Irvin Warren 58525 Manufacturing Engineer Use the outputinfo() method for each employee object to display the information on screen. For example: Employee e 4 = new Employee ("Oliver Mills", 12579); e4.department = "Accounting"; e4.position = "Vice President"; // Later in the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

10. Describe the relationship between communication and power.

Answered: 1 week ago