Click to See Complete Forum and Search --> : Help with debugging


abc4616
10-07-2006, 06:02 PM
This part of the program won't compile:


if (!editErrorFound)
{ if (hrs > 0 && rt > 0)
staff = new Employee (fn, ln, pos, rt, hrs );
else
staff = new Employee (ln,fn,pos);
}

What should I do? Here is the error statement:


C:\Documents and Settings\Desktop\Driver.java:250: cannot find symbol
symbol : constructor Employee(java.lang.String,java.lang.String,java.lang.String,float,float)
location: class Employee
staff = new Employee ( fn, ln, pos, rt, hrs);
^
1 error

Tool completed with exit code 1

Khalid Ali
10-08-2006, 07:17 PM
first of all, you would always want to put braces for if statements so that its not confusing.
Second if you look at the error, it actually explicitly tells you that an argument int he constructor is illegal.
Which means that you do not have a constructor that either takes 4 parameters or the first parameter is of wrong type. Hope this helps

Waylander
10-08-2006, 08:57 PM
Id recommend meaning full variable names.

Seems to me like your just calling a method that doesnt exist. Either add the parameter to the constructor, make a new constructor with those parameters or you can just make the parameters match the already declared constructor.

Waylandzor.

agent_x91
10-09-2006, 04:13 AM
You may be using the wrong type of arguments rather than the wrong number of arguments - make sure that the arguments for your constructor are (String, String, String, float, float) in that order. Also, I'd recommend using more descriptive variable names... "fn" and "rt" don't really help you much if you come back to the program after a few months.