This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have to create a program that outputs employee data. I read data from files, and I have to use these classes. I have not finished the output section yet, so I left it out for now.
I was wondering why I only get an [incompatible type] error for my accessor method in the grossPay class, when the accessor methods in the other two classes have nothing in them. Shouldn't they get some error?
Can anyone explain to me how to return these arrays correctly?
I was also wondering if I should put the write method in my main class, and if I initialized the arrays outside of the constructors correctly.
If there is anything incorrect with this code, please tell me what I should consider changing.
Thanks for any help you can give me.
The type of error you are suffering suggests you are trying to return numbers instead of numbers[i].
Have you been told you use all those arrays? That is hardly good design. You ought to have Employee objects which record hours worked, wage rates, etc. Put those objects into an Employee array
Joined: Oct 13, 2005
By the way, in a for loop to traverse an array, you should always use i < myArray.length; as its middle term. Introducing numbers (eg 4) make it error-prone. What will happen if you pass arrays with 3 or 5 members? And passing arrays of numbers rather than an Employee array is error-prone. What if the arrays aren't all the same size?