N
Newbie
heres the deal,
I have 3 seperate classes. ( 1. user Interface. 2.employee. 3.ordered
linked list )
1.
user enters ID and NAME for the employee using JOptionPane which the values
are then passed to the following method inside the userinterface class.
public void setup(int id, String name) {
emp = new Employee(); //Employee class instantiation
emp.setKey( id ); //sets the ID var
emp.setName( name ); //sets the NAME var
orderedList.insert( emp ); //Ordered List instantiation insert
}
2.
public class Employee implements Comparable {
private String name;
private int key;
public int compareTo(Object o) {
int result;
Employee empl = (Employee) o;
if (empl.key < key) { result = 1; }
if (empl.key > key) { result = -1; }
else { result = 0; }
return result;
}
public void setKey(int newKey) { key = newKey; }
public void setName(String Name) { name = Name; }
public int getKey ( ) { return key; }
public String getName() { return name; }
public String toString() { return "Id : "+key+" Name :
ame; }
}
3.
***** Snipped the insert ... etc methods *****
private class Node {
protected Object obj;
protected Node next;
public Node(Object obj, Node next) {
this.obj = obj;
this.next = next;
}
}
How in hells teeth can I implement a "search" method in the OrderedList
class that when an "int" is passed into the orderedlist class from the
userinterface class (using JOptionPane again) I can search for a specific
employee ID and then return the full contents of the Object with that
key.??!!
This has been driving me insane... I could really use some help with this as
I dont have the knowledge or skill to achieve what I want to.
Thankyou!
I have 3 seperate classes. ( 1. user Interface. 2.employee. 3.ordered
linked list )
1.
user enters ID and NAME for the employee using JOptionPane which the values
are then passed to the following method inside the userinterface class.
public void setup(int id, String name) {
emp = new Employee(); //Employee class instantiation
emp.setKey( id ); //sets the ID var
emp.setName( name ); //sets the NAME var
orderedList.insert( emp ); //Ordered List instantiation insert
}
2.
public class Employee implements Comparable {
private String name;
private int key;
public int compareTo(Object o) {
int result;
Employee empl = (Employee) o;
if (empl.key < key) { result = 1; }
if (empl.key > key) { result = -1; }
else { result = 0; }
return result;
}
public void setKey(int newKey) { key = newKey; }
public void setName(String Name) { name = Name; }
public int getKey ( ) { return key; }
public String getName() { return name; }
public String toString() { return "Id : "+key+" Name :
ame; }
}
3.
***** Snipped the insert ... etc methods *****
private class Node {
protected Object obj;
protected Node next;
public Node(Object obj, Node next) {
this.obj = obj;
this.next = next;
}
}
How in hells teeth can I implement a "search" method in the OrderedList
class that when an "int" is passed into the orderedlist class from the
userinterface class (using JOptionPane again) I can search for a specific
employee ID and then return the full contents of the Object with that
key.??!!
This has been driving me insane... I could really use some help with this as
I dont have the knowledge or skill to achieve what I want to.
Thankyou!