1 write a class named employeerec that has the following fields name the name field 5346954
1. Write a class named
EmployeeRec that has the following fields:
· name: The name field is a String object that holds theemployee’s name
· idNumber:The idNumber is an int variable that holds the employee’s IDnumber
· department: The department field is a String object that holds thename of the department where the employee works
· position:The position field is a String object that hold theemployee’s job title
§ Write appropriate mutator methods that store values in these fieldsand accessor methods that return the values in these fields.
§ Write the default constructor, the parameter constructor thatreceives 4 parameters of name, idNumber, department, position andthe copy constructor that accepts an employeeRec object.
§ Write toString method to display the contents as the followingformat:
Employee: Susan – ID: 47899– Department: Accounting – Position: Vice President
2. Write a separate programEmployeeReport.java
§ creates three EmployeeRec objects :
-Object employee1 by using thedefault constructor and mutator methods to set values of fields
-Object employee2 by using theparameter constructor.
-Object employee3 by using the copyconstructor.
The information of these objects asfollows:
Name |
ID number |
Department |
Position |
1. Susam Meyers |
47899 |
Accounting |
Vice President |
2. Mark Jones |
39119 |
IT |
Programmer |
3. Joy Rogers |
81774 |
Manufacturing |
Engineer |
§ display the data for each employee on the screen by using toStringmethod
Output should be:
Employee: Susam – ID: 47899 – Department: Accounting– Position: Vice President
Employee: Mark Jones – ID: 39119 – Department: IT– Position: Programmer
Employee: Joy Rogers – ID: 81774 – Department:Manufacturing – Position: Engineer
§ use the JOptionPane and the following example to display themessage Dialog box.
“Congratulations. You are successful to useobject!”
Hint: import javax.swing.JOptionPane;
JOptionPane.showMessageDialog(null, “the message”);