Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"IS-A" and "HAS-A" doubt

 
Kedar Pethe
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K&B question in self test-

Q - You’re designing a new online board game in which Floozels are a type of Jammers, Jammers can
have Quizels, Quizels are a type of Klakker, and Floozels can have several Floozets. Which of the
following fragments represent this design?


Why isn't Fragment 4 one of the correct answers??
 
Pritish Chakraborty
Ranch Hand
Posts: 91
C++ Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because Floozel does not HAVE-A Floozet.

Here it IS-A Floozet.
 
Kedar Pethe
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pritish Chakraborty wrote:Because Floozel does not HAVE-A Floozet.

Here it IS-A Floozet.


oh.. So simple!!
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pritish Chakraborty wrote:Because Floozel does not HAVE-A Floozet.

Here it IS-A Floozet.


Floozel HAS-A Floozet as per the question. The point here to take away is the following:

(1) IS-A relationship represents Inheritence
(2) HAS-A relationship represents Composition

Hope that was clear.
 
Pritish Chakraborty
Ranch Hand
Posts: 91
C++ Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, I didn't get you....

Of course those two points are very clear but here Floozel and Floozet are two interfaces linked through inheritance, not through composition.

How does the HAS-A relationship come into question at all?
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pritish Chakraborty wrote:I'm sorry, I didn't get you....

Of course those two points are very clear but here Floozel and Floozet are two interfaces linked through inheritance, not through composition.

How does the HAS-A relationship come into question at all?


Doesn't this sentence say that?



I would infer the following:

Quizels extends Klakker (are a type of Klakker) and when Floozels can have several Floozets, would mean Floozels has one to many Floozets as its member. How could I apply IS-A relationship here? Do you understand it now?

By the way, Answer option 4 is wrong. Any wrong answer in the SCJP exam is just to confuse you. The interface in the option 4 above is also to confuse you.
 
Pritish Chakraborty
Ranch Hand
Posts: 91
C++ Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My dear sir, with all due respect, I did read the question. I don't know if you did however.

The original poster was asking why the fourth fragment was wrong.

And it is wrong because the HAS-A relationship of Floozel and Floozet is NOT maintained, which is required as per the question.

It does not hurt to reread the query

Yes, we know option 4 is wrong. He was asking why it is wrong.

Good day to you, sir.
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pritish Chakraborty wrote:My dear sir, with all due respect, I did read the question. I don't know if you did however.

The original poster was asking why the fourth fragment was wrong.

And it is wrong because the HAS-A relationship of Floozel and Floozet is NOT maintained, which is required as per the question.

It does not hurt to reread the query

Yes, we know option 4 is wrong. He was asking why it is wrong.

Good day to you, sir.


I don't get you. If you understood the question, then why ask the following in your post above?




 
Pritish Chakraborty
Ranch Hand
Posts: 91
C++ Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me clarify this confusion once and for all.

My reply to the OP's query was with respect to the code fragment he posted. He asked why it is wrong.

I answered why it is wrong.

The quote of my post which you have put in </code> tags was asked to you : because you were stating the obvious, and not answering the OP's query.

You were informing me what IS-A and HAS-A relationships are about, whereas the thread had gone in a completely different direction and had already been resolved.
 
Joe Harry
Ranch Hand
Posts: 10124
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pritish Chakraborty wrote:Let me clarify this confusion once and for all.

My reply to the OP's query was with respect to the code fragment he posted. He asked why it is wrong.

I answered why it is wrong.

The quote of my post which you have put in </code> tags was asked to you : because you were stating the obvious, and not answering the OP's query.

You were informing me what IS-A and HAS-A relationships are about, whereas the thread had gone in a completely different direction and had already been resolved.


The idea here is to mention about composition and Inheritence which I felt I did!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic