Assignment 1 is to practice creating classes, attributes, methods, and basic syntax and flow control. There are two parts in this assignment.
Part 1
You will create two classes, Employee and EmployeeTable. Employee represents an employee record in a table of employee records. It will have three attributes: employee number, employee name and salary. Employee class also has methods that allow other objects to change its attributes or print out all its attributes.
EmployeeTable represents a table of employee records with a company. This class has two attributes: the name of company and the actual table that contains all the employee records. The latter can be implemented using a Java library class Hashtable.
The class EmployeeTable will have behavior/methods that allow other objects to call to do the following:
Get the total number of employees in the table
Insert an employee in the table, the employee object being passed to the method
Delete an employee from the table, the employee number being passed to the method
Update an employee in the table, the employee number being passed to the method
Part 2
You will create a test class that instantiates a new EmployeeTable and then loops infinitely to take some user input from console and then allows user to invoke one of the methods of the EmployeeTable to insert, delete or update an employee record in the table. The test program will exit if user enters Q on the console.
Some example output is as follows:
EmpClient.main(): client started...
[L]ist| [A]dd | [E]dit | [D]elete | [Q]uit: a
Adding a new employee...
Enter a string value for empNo: emp-01
Enter a string value for empName: George Bush
Enter a float value for salary: 80000
Employee added:
emp-01, George Bush, 80000.0
[L]ist| [A]dd | [E]dit | [D]elete | [Q]uit: a
Adding a new employee...
Enter a string value for empNo: emp-02
Enter a string value for empName: Greg Harper
Enter a float value for salary: 50000
Employee added:
emp-02, Greg Harper, 50000.0
[L]ist| [A]dd | [E]dit | [D]elete | [Q]uit: a
Adding a new employee...
Enter a string value for empNo: emp-03
Enter a string value for empName: Brad Linsley
Enter a float value for salary: 45000
Employee added:
emp-03, Brad Linsley, 45000.0
[L]ist| [A]dd | [E]dit | [D]elete | [Q]uit: l
Listing all employees...
3 employees found:
emp-03, Brad Linsley, 45000.0
emp-02, Greg Harper, 50000.0
emp-01, George Bush, 80000.0
[L]ist| [A]dd | [E]dit | [D]elete | [Q]uit: e
Editing an employee...
Enter a string value for empNo: emp02
No record exists for emp02
[L]ist| [A]dd | [E]dit | [D]elete | [Q]uit: e
Editing an employee...
Enter a string value for empNo: emp-02
Enter a new string value for empName: Brad Linsle
Enter a new float value for salary: 55000
Employee updated:
emp-02, Brad Linsley, 55000.0
[L]ist| [A]dd | [E]dit | [D]elete | [Q]uit: d
Deleting an employee...
Enter a string value for empNo: emp-01
Employee deleted:
emp-01, George Bush, 80000.0
[L]ist| [A]dd | [E]dit | [D]elete | [Q]uit: l
Listing all employees...
2 employees found:
emp-03, Brad Linsley, 45000.0
emp-02, Brad Linsley, 55000.0
[L]ist| [A]dd | [E]dit | [D]elete | [Q]uit: q
EmpClient.main(): client exiting...
Done.
It will have three attributes: employee number, employee name and salary. Employee class also has methods that allow other objects to change its attributes or print out all its attributes.