Wrox Programmer Forums
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 3rd, 2006, 09:33 AM
Authorized User
 
Join Date: Oct 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to SiliconFuRy
Default OOP Design Prob

I have a problem in my coursework, which can be illustrated here:
http://www.thebigman.co.uk/james/prob.JPG

What I want to do is to call Programmer.assignMentor() from within SoftwareHouse.assignMentor, I know I'm unable to do this, because I am iterating through a collection of "Employable" objects, but I don't want to define a prototype for "assignMentor" within the Employable Interface, because this method is a particular specialisation.

Any ideas on how I could overcome this issue? I'm using Java 5.0

Many shoes,

Jamez/SiliconFuRy

EDIT: I'm aware that SoftwareHouse.assignMentor assigns a mentor to itself, I'll sort this minor inconsitency once I'm able to called Programmer.assignMentor() (the parameter for this call should be the "mentee" passed to to the SoftwareHouse.assignMentor method).
__________________
Many shoes,

Jamez/SiliconFuRy
 
Old April 6th, 2006, 03:01 PM
Authorized User
 
Join Date: Oct 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to SiliconFuRy
Default

Solved it myself using the following code, lol.

/**
     * Assigns a mentee programmer to a more experienced mentor programmer.
     * First it calls findEmployee to get an object representing the Mentor,
     * then checks to make sure its a programmer. Then a programmer type is
     * casted so it can be properly passed to Programmer.assignMentee.
     * findEmployee is called again to get an object representing the Mentee,
     * then checks to make sure this is also a programmer. Another programmer
     * object is created from a type cast of the Mentee. Programmer.assignMentee
     * is finally called, passing the mentor and mentee programmer objects.
     *
     * @param mentor
     * The Programmer's payroll number who will be assigned as a
     * mentor
     * @param mentee
     * The Programmer's payroll number of the mentee which will be
     * assigned to the mentor
     */
    public void assignMentor(String mentor, String mentee) {

        Employable mentorEmployee = findEmployee(mentor);
        if (isProgrammer(mentorEmployee)) {
            Programmer mentorProgrammer = (Programmer) mentorEmployee;

            Employable menteeEmployee = findEmployee(mentee);
            if (isProgrammer(mentorEmployee)) {
                Programmer menteeProgrammer = (Programmer) menteeEmployee;

                mentorProgrammer.assignMentee(menteeProgrammer);
            }

        }

    }

Many shoes,

Jamez/SiliconFuRy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Classes (OOP) in VBScript 6 benr Pro VB 6 12 March 13th, 2006 04:02 PM
OOP design raj_sekhar C++ Programming 1 August 23rd, 2005 11:44 AM
passing a php oop object in a form buckarette Pro PHP 2 December 24th, 2003 07:49 PM
OOP with JavaScript Moharo Javascript 3 September 29th, 2003 10:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.