Re: Java/OOP Question/Problem



Eric Sosman wrote:

Your wife says "Honey, I want a Poodle, which, as you
know, is a specific kind of Dog." So you go to the pet
store and buy a Schnauzer, which is also a specific kind
of Dog. Will your wife be satisfied?
Not true whatever she asks for and I giver her she is never satisfied :)

The method says "I want an ImageFrame, which, as you
know, is a specific kind of Frame." So you go to the window
store and buy a JFrame, which is also a specific kind of Frame.
Will the method be satisfied?

I am guessing not :)

"To achieve this ..." Well, it depends what you mean by
"this." If you mean "Make the method accept my JFrame even
though it's not an ImageFrame, as required," the answer is no:
You cannot do it. Your wife wants a Poodle and will not accept
a Schnauzer instead, even though both are Dogs.
Please understand even if I gave my wife the damned poodle she would still not be satisfied :)

But if you mean "Make the method accept my own extension
of ImageFrame," the answer is yes. Create your own BlokeFrame
class that extends ImageFrame, endow it with whatever methods
you like, and pass a BlokeFrame to the method. Since your
BlokeFrame *is* an ImageFrame, the method accepts it. Your
wife will be happy if you bring her a Miniature Poodle or a
Toy Poodle or a Standard Poodle; all are Poodles.
She still wouldn't be satisfied with all or any of the above :)

Hmmm this was as I feared. It would have been better if the method took an Interface or Frame reference, problem solved :), but this is not the case :( is there a way I can make a Frame look like a JFrame? I tried your way and it works as expected because of the is-a relationship, but it looks fugly compared to the other windows, even playing with the look-and-feel voodoo of AWT I want my new BlokeFrame to look like a nice Windows XP Frame :) like all the other frames :p.

Thanks for your help anyway

DB


.



Relevant Pages

  • Re: Evolutionary compassion
    ... there is no value in a dog taking care of a cat. ... becomes proposed which can act as a critical Galilean frame of reference. ... missing, critical, constant frame of reference within any Neo Darwinian ...
    (sci.bio.evolution)
  • Re: Evolutionary compassion
    ... there is no value in a dog taking care of a cat. ... becomes proposed which can act as a critical Galilean frame of reference. ... missing, critical, constant frame of reference within any Neo Darwinian ...
    (sci.bio.evolution)
  • Re: Christmas Gifts?
    ... If I killed the poodle, Caroline would be more upset than at the loss ... Now then, in the morning, normally you let the dog out for a piss. ... was like something out of 'Jaws' ...Duh di duh di duh di duh ... of crisps, put Max on a lead, sat them both down at ...
    (rec.music.makers.guitar.acoustic)
  • Re: Christmas Gifts?
    ... If I killed the poodle, Caroline would be more upset than at the loss ... My M.I.L. has two cats. ... Now then, in the morning, normally you let the dog out for a piss. ... was like something out of 'Jaws' ...Duh di duh di duh di duh ...
    (rec.music.makers.guitar.acoustic)
  • Re: Christmas Gifts?
    ... If I killed the poodle, Caroline would be more upset than at the loss ... Now then, in the morning, normally you let the dog out for a piss. ... was like something out of 'Jaws' ...Duh di duh di duh di duh ... Jaws like a shark. ...
    (rec.music.makers.guitar.acoustic)