A source of possible error in this adventure game is that the names for the rooms appear
Question:
A source of possible error in this adventure game is that the names for the rooms appear in several places. If the Dining Room is spelled “DiningRoom” in one place and “DinngRoom” (missing the second “i”) in another place, the game won’t work correctly. The more rooms you add, and the more places where you have the room names typed, the odds increase that the error will be made.
There are a couple of ways of making this error less likely to occur:
• Do not name the rooms with strings of characters. Instead, use numbers. It’s easier to type and check “4” than “DiningRoom.”
• Use a variable for DiningRoom and use that one variable for checking the location. Then it doesn’t matter if you’re using numbers or strings (and strings are much easier to read and understand).
Use one of these techniques to rewrite the adventure game with fewer potential errors.
Step by Step Answer:
Introduction To Computing And Programming In Python A Multimedia Approach
ISBN: 9780134025544
4th Edition
Authors: Mark J. Guzdial, Barbara Ericson