So I got this in a main program. As visible below I am first trying to edit the pay "45.0" by a raise of 10% of a single Employee object. Here I am making sure that my math calculation are correct. In another class I need to write a code to add the 10% to all the Employees.
temp.obj.getData()
shows all the Employee data entered in the main class while the new object e
is empty. Does someone know how I can get the data from the main program to object e or without creating object e. My problem is that when I am doing the same operations on object e the calculation of the pay are all 0. I think this is due to pay = 0
. I seem to have a problem of getting the data (pay values ) from the objects in main class. Can someone help? Thanks if there is the need of more code ask me.
MAIN PROG:
etemp[15] = new Employee(134, "Nicole", 45.0);
queue.put(etemp[15]);
if(queue!=null){
//Attempt 1 : Editing pay of a single employee
System.out.println("not empty!");
double x = etemp[15].getSalary();
double calc = (x*0.10)+x;
etemp[15].setPay(calc);
System.out.println("Raise: "+etemp[15].getData());
//Attempt 2 : Using a method to edit pay of ALL employee
queue.pay(10);
} else {
System.out.println("empty");
}
METHOD IN OTHER CLASS:
public void pay(int p){
int id = 0;
String k = "";
double pay = 0;
Employee e = new Employee(id, k, pay);
CircQueue q = new CircQueue(20);
if(rear!=null){
Node temp=front;
do{
for (int i= 0; i<currNodes; i++)
{
System.out.println(temp.obj.getData());
q.put(e);
q.listAll();
double x = e.getSalary();
double calc = (x*0.10)+x;
System.out.println("Raise: "+calc);
temp = temp.next;
}
}while(!(temp==rear.next));
} else System.out.println("Empty queue!");
}