[Bluej-discuss] Questions on Chapter 9.

Michael Kölling M.Kolling at kent.ac.uk
Mon May 8 17:55:36 BST 2006


In any case of deciding on an inheritance relationship, you have to  
ask yourself whether the classes (here: Monster and Player) have  
anything in common so that they can - at a certain level of  
abstraction - be viewed as two specialisations of the same concept.

Or more concrete: do they share state (instance fields) or behaviour?

In this case, both the monsters and the player are entities that move  
around in the game map. This whole sub-task could be moved into a  
superclass (storing the current room, moving to another room, etc)  
even though the details of movement are probably different (maybe  
random for a monster and input-controlled for the palyer.

There are other things that may be common (depending on your game  
design): strength, hunger, tiredness, health, etc. If there are  
similarities, these can be moved into a superclass (maybe named  
"GameCharacter"?).

Michael


On 8 May 2006, at 17:37, RDP wrote:

> Specifically,
>
> Using inheritance in the ZUUL project to implement a player and  
> monster class.  Just to see the mechanics of how this (inheritance)  
> would look and execute.
>
> Thanks Michael.
>
> Rob
> ----- Original Message -----
> From: Michael Kölling
> To: RDP ; General discussion for users of BlueJ
> Sent: Monday, May 08, 2006 10:38 AM
> Subject: Re: [Bluej-discuss] Questions on Chapter 9.
>
> Rob,
>
> Can you be a little more specific - what are your questions?
>
> Michael
>
> On 6 May 2006, at 04:54, RDP wrote:
>
>> Help with Chapter 9
>>
>> Can anyone offer any help with Chapter 9 and the following exercises?
>>
>> Exercises 9.10 and 9.11 on page 263
>>
>> and
>>
>> Exercises 9.15 and 9.16 on page 265.  (Could use help with the  
>> inheritance explanation here)
>>
>> Please reply!
>>
>> Rob
>> _______________________________________________
>> mailing list bluej-discuss at bluej.org
>> To unsubscribe or change your preferences, go to
>> http://lists.bluej.org/mailman/listinfo/bluej-discuss
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.bluej.org/pipermail/bluej-discuss/attachments/20060508/0d990831/attachment.html


More information about the bluej-discuss mailing list