This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java and have Dr. Raoul-Gabriel Urma & Richard Warburton on-line!
See this thread for details.
Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

A good question

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q) A tennis coach is a student and a trainer? How could we represent it in a diagram?
 
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 Polymorphism pattern here.
Comments,please
-- Sandeep
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Adrian Ferreira
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Desai,
I agree, that is true.
Thanks for your explanation.
Adrian
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Adrian Ferreira
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

A tennis coach is a student and a trainer?


Adrian
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Having an abstract "Coach" class beats me!!!
Sorry! i am also new to modeling
so would it be like..........

what good is the getIndividual() method for?
How do i return a Coach(abstract)class object?
thanks
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!