File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Has-A relationsship explanation

 
ranjan sarkar
Greenhorn
Posts: 7
  • 0
  • 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
  • 0
  • 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: 47229
52
  • 0
  • 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic