|
From: Mamutas P. <ma...@pr...> - 2004-03-12 02:42:25
|
If you want particular set of objects to expose common behavior, then you should create an interface with methods for that behavior and inherit all objects from it. In this case, I think good idea would be to have interface IHandHeld, which will define methods particularly for objects in the person hand. The interface would have methods like: canThrow(), canShoot(), throw(), shoot(), etc. First two methods will let caller know whether the action is available (and actually does something). Second two methods will perform the action itself, if it is applicable to the object (shoot() may not be applicable to knives, so it will have no operation implementation). Does it make sense? Regards, mamutas -----Original Message----- From: Tamas Terpai [mailto:te...@cs...] Sent: Wednesday, March 10, 2004 8:13 AM To: mamutas Subject: Re: [Xenocide-programming] datainterfaces update On Sun, 7 Mar 2004, mamutas wrote: > ICarriable just determines that item can be carried. If you want your item > be able to fire or thrown, then other appropriate interface must be > employed. > And how do I determine which classes did the item in the player's hand inherit? Try to call the appropriate function and catch the exception? I'm sorry, but it's absolutely unclear for me. --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.616 / Virus Database: 395 - Release Date: 3/8/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.616 / Virus Database: 395 - Release Date: 3/8/2004 |