[Bluej-discuss] Exercise 7.22 pag 204

Michael Kölling M.Kolling at kent.ac.uk
Tue Mar 21 10:02:32 GMT 2006


Luis,

I think that's a very good solution. That's how I would have done it  
as well.

This way, the Game class just says "give me a description of what I  
can see in the room" and everything else is up to the room to handle.  
This could be an item, many items or, in fact, could include other  
characters, monsters, or whatever the room happens to hold. Nicely  
decoupled from Game.

Michael



On 21 Mar 2006, at 08:54, Luis Moreira wrote:

> Hi all,
>
> I found a solution for the problem in this exercise but I need an  
> opinion on the quality of the solution.
>
> What I have done was to Iterate trough the ArrayList where I stored  
> the Item objects and extracted the description and the weight  
> information and kept on adding it into a String, When the iteration  
> is finished I pass this String to Game for printing. Is this a good  
> solution? As I see it I maintain a very loss coupling , Game as no  
> idea about item only class Room as any connection with that class,  
> I could change Item and the only class I would have to maybe change  
> would be Room but not in a way that would affect Game and vice-versa.
>
> Opinions welcomed.
>
> Best regards
>
>                         Luis
>
>
>
>
> _______________________________________________
> mailing list bluej-discuss at bluej.org
> To unsubscribe or change your preferences, go to
> http://lists.bluej.org/mailman/listinfo/bluej-discuss



More information about the bluej-discuss mailing list