Your worst problem lies, as I always said, in the SoftwareHouse.addMenteeToMentor functions. Aside from being very inefficient in its lookup (it traverses the list three times!), it has a very bad piece of code:
Code:
if(prog instanceof Mentor) {
((Mentor)prog).addMentee(mentee);
} else {
Mentor mentormain = new Mentor(mentorname, mentorpn, mentorSalary, calcyob, mentorproglang); //get all details
mentormain.addMentee(mentee);
theStaff.add(mentormain);
//!!remove this current programmer which is a mentor!!
//theStaff.remove(prog);
}
What is bad about this code? It alters the structure about the list. It shouldn't. There could be a reference to this programmer somewhere, and you remove that. You might create loose ends.
Besides, it's simply stupid. It is a feature of a Programmer that he can be mentor to another programmer if he has enough experience. He doesn't becomes someone different. As I said so often before, get rid of the Mentor class! Build the functionality into Programmer.
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
ok - seems to be doing it ok but ran into another problem
when we make the programmer into a Mentor after all equality checks - it displays the details twice
it works fine if we enter the emp number 171 which is a mentee - finds the correct mentor and assigns it and shows the mentors details
however - if we enter 123 as a mentee payroll number - it doesnt do it right
first it shows Euan who is 28 and increases its salary and says that the mentee is assigned to Euan
then it goes to the CORRECT record (darren) and increases its salary and shows its mentee.
whats going on?
i thnk it has to do with something here:
Code:
if(prog instanceof Mentor)
{
((Mentor)prog).addMentee(mentee);
ConsoleIO.out.println("Mentor was created - Mentor now has these Details: \n\nMentor info: \n\n" + ((Mentor)prog).toString());
}
else
{
Mentor mentormain = new Mentor(mentorname, mentorpn, mentorsal, mentoryob, mentorproglang);
theStaff.add(mentormain);
mentormain.addMentee(mentee);
ConsoleIO.out.println("\nExisting Mentor was found \n\tMentor info \n\n" + mentormain.toString());
}
i attached the new code anyway - i think you will see the problem (i hope)