> In this video -
> http://video.google.com/videoplay?docid=448441135356213813&q=common+lisp&total=1
4&start=0&num=10&so=0&type=search&plindex=0
[quoted text clipped - 14 lines]
>
> and so on?
You can, but the class containing the static methods would have N*M
methods, where N is the number of media and M is the number of displays.
It would have to be updated for addition of either a new medium or a new
display type.
Ideally, one would implement e.g. paper tape input by adding a class
PaperTape, implementing the same interface as Book, CD, and DVD, and
that would be the end of the matter.
Patricia
Eric Sosman - 24 Aug 2007 17:49 GMT
Patricia Shanahan wrote On 08/24/07 11:06,:
>>In this video -
>> http://video.google.com/videoplay?docid=448441135356213813&q=common+lisp&total=1
4&start=0&num=10&so=0&type=search&plindex=0
[quoted text clipped - 23 lines]
> PaperTape, implementing the same interface as Book, CD, and DVD, and
> that would be the end of the matter.
Also, note that Java's determination of which method
to call depends on the compile-time types of the arguments,
not their run-time types. If all these things are subclasses
of Media and Display, as appropriate, then
Media m = new Book();
Display d = new TextDisplay();
display(m, d);
... will *not* call the first of your static functions.

Signature
Eric.Sosman@sun.com