Hi, You could make Coach as an abstract class which has a method getIndividual(), which returns Coach.This method would be implemented by the Student and Trainer class, which inherits from class Coach.So we can use the Polymorphismpattern here. Comments,please -- Sandeep
Hello, Honestly, I would represent as Student interface, another Trainer interface and a Coach class that implements both Student and Trainer. Sorry if it does not meke much sense, I am completly new on this topic. Adrian
Adrian, It depends on what you want.If you want, the "Coach" to be of the type of "Student" and "Trainer" then having "Student" and "Trainer" as interfaces and implementing them as a "Coach" class makes sense.This would mean "Coach as a type of Student and Trainer". However, if you want the "Coach" to be either a "Student" or "Trainer" then making "Coach" as an abstract class is a better solution. Hope this helps, Sandeep SCJP2,OCSD(Oracle JDeveloper),OCED(Oracle Internet Platform) [This message has been edited by Desai Sandeep (edited August 21, 2001).]
Another possibility would be to define a Role interface, let Student and Trainer implement Role, and let Coach have an one to many association to Role. As others said, it heavily depends on the wider context.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Hello, I am following the discussion but I am a bit confused regarding the functions of the coach. Are we talking about just two functions like a person (who is the coach) can be a student and a trainer, or three functions: a person can be a coach, a student or a trainer? The reason I ask this is if we make the coach as an abstract class and if the coach is a another function, how can we make an instance of that class. Well, I don't know, maybe I am speaking out of context. Any clarification, please. Ted
Ted, I think you understand. This discussion became more generic. In some models described here, like that using two interfaces, you can only have one instance (class Coach) that works like Trainer and Student since Interface as well as abstract class can not be instanciated. Other model suggests that your Coach object can be either a Student or a Trainer as explained before. Actually, the first question asks for the "and", not "or" condition.