Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Has-A relationsship explanation

 
ranjan sarkar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q)Man has a best friend who is a Dog
How you can explain this with Has-A relation
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Man has a bestFriend. hence man will have a bestfriend variable.
......who is a Dog. hence bestFriend is an instance of class Dog.

avi sinha
 
Campbell Ritchie
Sheriff
Pie
Posts: 48950
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Man-Dog example is called "association"; a Man does not cease to be a Man if the Dog dies.

The examples I have given are called "composition"; an Aeroplane without a Wing is no longer an aeroplane in the fullest sense of the word. And if you disagree, try taking the wings off your aeroplane at 29000 feet
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic