Campbell Ritchie wrote:Welcome to the Ranch
Please don't post your question on somebody else's thread; fortunately I can split your question into a new thread. Always use the code button; I have edited your post with it and doesn't it look better
Junliu is right; you should pass employee objects to the payroll class. I can see other problems; you have a constructor which doesn't set the name. You can have an employee who goes through thier whole employment history without knowing their name. Make sure all constructors set up the name; you cannot rely on outside code calling the setXXX methods. You should therefore not try to enrol anybody with a number and no name. You may have to implement a getNextID method in the payroll class.
If you're not looking to an exercise as to an interesting challenge, might this field (programming) is not for you. Telling that you're getting sick of that won't solve exercices, we're here to tackle problems rather than moan. Nor moralize So let's get back to your problem.Alex O'Dowd wrote:Could you just give an example, few lines how to ?
Getting sick already with that.
Liutauras Vilda wrote:
If you're not looking to an exercise as to an interesting challenge, might this field (programming) is not for you. Telling that you're getting sick of that won't solve exercices, we're here to tackle problems rather than moan. Nor moralize So let's get back to your problem.Alex O'Dowd wrote:Could you just give an example, few lines how to ?
Getting sick already with that.
Please show us what have you tried after you got few good suggestions. In case you actually don't know where to start, try to revise your lecture slides. Such techniques had to be shown and documented in one of your class sessions.
Please show us, what material you got and which parts are not clear, so as a result you're not entirely sure where to start.
Alex O'Dowd wrote:I tried to code As a result, while trying to run it I get error: Payroll cannot be applied to given types;
required: Employee
found: java.lang.String
reason: actual argument java.lang.String cannot be converted to Employee by method invocation conversion
Alex O'Dowd wrote:It all compiles fine, then when I try to run it :
Payroll aPayroll = new Payroll();
aPayroll.enrollEmployee("1200");
Error: line 1 - method enrollEmployee in class Payroll cannot be applied to given types;
required: Employee
found: java.lang.String
reason: actual argument java.lang.String cannot be converted to Employee by method invocation conversion
Alex O'Dowd wrote:Could anyone help, how implement enrollEmployee() which takes a string representation of an employee number as its argument and then add employees with employee number