Does the Animal Game Fit the Criteria?


You betcha. Here they are again:

  • Output strings: The program needs to give the user instructions and to respond to his responses to your questions.

  • Input: The program needs to take strings from the user and do something with them. The dialog nature of the problem requires some (but not much) parsing of the input.

  • Simple algorithm: The program is going to branch to different questions depending on the answers. Thus, depending on the "Yes" and "No" responses, it will traverse a data structure.

  • Interaction with a permanent store: The program needs to keep the current animal and question database file somewhere, and read it in on program invocation. This data will be used to exhaust the question set. If the program does not guess the animal, it will have to update the file with the new animal and the new question. Then it will have to store these for the next user session.

  • Prototypical data structure: Once again, the program will traverse some sort of linked list to achieve the result. When the user adds a new animal and a new question, the program will have to add those links and update some of the old links to point to the new information.

  • Error handling: The program needs to be able to deal with blank input from the user when actual values are required, and it has to cope with the data file's being corrupted. This area has lots of latitude, depending on how user-friendly you want the program to be. For example, what do you do if the user quits halfway through?

  • Abstraction and encapsulation: You can easily generalize the problem to be a vegetable game, a mineral game, or a famous-person game. These variations should depend only on loading a different data file; the language should let you do all of them with the same program.

Note that I have kept this very simple. For example, you shouldn't allow several people to play the game simultaneously; this would vastly complicate the problem. But even for serial interactions by different users, it makes for a nice programming problem.




The Software Development Edge(c) Essays on Managing Successful Projects
The Software Development Edge(c) Essays on Managing Successful Projects
ISBN: N/A
EAN: N/A
Year: 2006
Pages: 269

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net