Paul Di

Greenhorn
+ Follow
since Feb 09, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Di

Well I did get the issue solved. It was just a matter of needing to override the toString() method in the Employee class.
11 years ago
So I am slowly making some progress but I am having some issues. I am trying to pass an object as the value to the hash table, however when I hit "L" for list and try to print out the hash table I only see what ever value is entered for "please enter employee ID number". Just wondering if you could give me an idea what I am doing wrong. I know there is other methods still to fill out but for now I am just working on adding employees to the hash table and printing out a list of the employees that have been added to the hash table.

test class


EmployeeTable class


Employee Class


Sample of the output
11 years ago
Hello everyone,

Sorry if it seems like I need to be spoon fed because that how I feel. I am usually a quick learner but that does not seem to be the case with java. I am learning C# and feel like I am catching on quickly but I feel very frustrated that I can not even complete my java first assignment.

I have been reading as much as possible and watching the tutorials, I plan to continue to do both.

I am hopeful someone would be kind enough to point me in the right direction so I can complete my assignment. Any help at all would be very much appreciated.

Here is the assignment I need to complete


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.



Question about part 1,

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.


Is it as simple at this?
private String empName;
private int empNo;
private double empSalary;

I am having an issue getting the employee Class started.

template for EmployeeTable. I have started the update method. I don't really understand what is being passed in to the method to be honest.


Part 2: Test class started (some of this was provided in a template and I realize the is code that needs to be added in the switch statement. Case L needs System.out.println(table.toString()); etc.


If anyone could help me out, I would greatly appreciate it. In the mean time I will continue to read until my eyes bleed. Thank you for your time.
11 years ago