Results 1 to 4 of 4

Thread: information is not updated

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    information is not updated

    Hi again


    i hope i have done my mentor mentee thing - it seems to work (FINALLY!!!)

    if it doesnt i will cry and the first part of the coursework is due on thursday


    the part im stuck on now is:


    when the mentor adds a mentee to its list - it will not update the salary and it wont show its mentee's when displaying the stafflist/staffdetails.


    i spoke to another lecturer and he told me to do it anotherway - spent 6 hours trying to do it and the result was the same as i already had!


    so now - im sticking to it my way and i need some help

    only 3 small thing - why doesnt it work?


    i have attached the files.

    i hope it is easy to understand and i hope u can explain easily whats wrong

    thanks
    Attached Files Attached Files

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773
    i kinda sorted it - will look more closly at how i sorted it


    but the Mentor class MUST be there - that is what the lecturer said and yes - i understand what you mean by this

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773
    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)
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width