Often we will want to handle mixed lusts of objects – for example, a Room may contain a list containing Treasure, MagicTreasure and Weapon objects – that is, objects derived from three different classes. Each object has a different Describe() method. So how can we be sure that the correct version of the method is called when we iterate over a list (in which we can’t know in advance which type of object each list element actually is)?
The answer is virtual methods which are overridden?
WHAT???
This may sound complicated but it isn’t really. As I explain in this lesson.
To follow this course, bookmark the Complete Course In Adventure Game Programming Playlist:
• Complete Course in Adventure Game Pro... Huw Collingbourne is author of The Little Book Of Adventure Game Programming In C#. Available from:
* Amazon (US)
amzn.to/33M6sQ4 * Amazon (UK)
amzn.to/2YtaBrj And also, The Little Java Book Of Adventure Game Programming. Available from:
* Amazon (US)
amzn.to/3gizI93 * Amazon (UK)
amzn.to/3mydF0e If you are eager to get working on your own adventure game, you can download Huw’s free game-writing code libraries, BIFF (the Bitwise Interactive Fiction Framework) from:
www.bitwisebooks.com/ Facebook:
www.facebook.com/CodeWithHuw
@jameslavery2958
1 year ago
This has been a fantastic series so far. I always wanted to see how text adventures were coded. You've shown a light for me. I will definitely be getting the C# book. I had no idea how to make a parser that actually 'tokenized?' the sentence - and how to check for proper usage - verb, verb noun, verb adjective noun, verb noun prep noun, etc. Is this the end of the course? I hope not. You do a really good job in teaching. Regardless, thanks for giving back to the community... especially us "older guys" that spent hours figuring out text adventures like the Zork series, among others. Such fond memories... I really hope that you keep going on this series. Thanks again.
|