CS 242 Spring 2010 : Assignment 3

This page last changed on Mar 19, 2010 by m3rabb.

Assignment 3 – The Animal Quiz

Congratulations, you have made it past the first two assignments and it is now time to complete the last one before you start on your final semester project. Assignment 3 is a 1 week long assignment that will consist of two parts. This assignment will be due on Thursday, April 1st at 8:00am CST in subversion. Please place your submission in a folder at the root of your repository named Assignment3.

Your project proposal is due Wednesday March 31st at noon. See below.

Part I – Creating the Animal Quiz

Objective: Build a simple decision engine
Language: Any language of your choice that allows you to complete all aspects of the assignment

Note: Since we allow you to use the language of your choice, you should read though this assignment specification in its entirety before you begin working to ensure that your choice will facilitate completing the assignment!

You will be implementing a simple console animal quiz that will try to guess an animal that you are thinking of, similar to the popular 20 questions game. You can find an online implementation here.

Here is an example run of the program. When it is run for the first time, the only animal it knows about is a whale.
Text in bold is user response.

Think of an animal…
Is it a whale? (y or n)
You win. Help me learn from my mistake.
What animal were you thinking of?
a rabbit
Give me a question to distinguish a rabbit from a whale.
Is it a small animal?
For a rabbit, what is the answer to your question? (y or n)
Play again? (y or n)
Think of an animal…
Is it a small animal? (y or n)
Is it a rabbit? (y or n)
You win. Help me learn from my mistake.
What animal were you thinking of?
a capybara
Give me a question to distinguish a capybara from a rabbit.
Is it a kind of rodent?
For a capybara, what is the answer to your question? (y or n)
Play again? (y or n)
Think of an animal…
Is it a small animal? (y or n)
Is it a kind of rodent? (y or n)
Is it a capybara? (y or n)
I win.
Play again? (y or n)
Thanks for playing!

In summary, the program asks the user to think of an animal and then asks a series of questions to narrow the possibilities. When the program guesses wrongly, it asks the user to supply a question that can help it determine that animal in the next run. Do not worry about the ‘a’ and ‘an’ particle for the animal. Just treat everything as being addressable by ‘a’.

Part II – Persisting Your Program’s Data

For the second part of this assignment, you will modify your decision engine so that it stores the knowledge that it learns to disk. When you finish this part of the assignment, your program should be able to save all its learned knowledge to disk and be able to load it all back again when it is run such that it picks up where it last left off.

To save and load your data, you must use XML as the storage medium. It is up to you to create the XML schema that will store your data, but thinking of your data as a binary tree and then trying to map that data into and out from a XML file might be helpful.

We encourage you to use any XML library that is available for the language you choose to complete this part of the assignment. In fact, it would be to your disadvantage to not do so.

As usual, post any questions you have to the newsgroup and one of the staff members will try to help you out as quickly as possible.

Part III – Final Project Proposal

For the last 4 weeks of the semester, each of you will complete your own final project. The project can cover any domain using any language, toolkit, or framework, but you cannot have your final project for this course be part of a project or assignment for another course you are currently taking. Before you can begin your final project, you must first write up a proposal and submit it to your section leader for approval. The proposal must contain:

  • Summary of application including functionality, language used, libraries needed, platforms targeted, etc
  • Why you chose this application (i.e. to learn something, to solve a problem…)
  • Who will use this application when it is completed
  • List of features
  • How you plan to test the application (will you use junit, nunit, selenium, etc)
  • Documentation plan
  • A weekly schedule
    • You have 4 weeks to complete the project
    • For each of the 4 weeks, you need to commit to which portions and features will be complete

We expect you to spend the same amount of time each week on the final project that you spend on each of the other assignments so far this semester, so plan out each week accordingly. Your TA might ask you to revise your proposal after submitting it if he thinks that you are trying to do to much or too little. Submit your proposal as a pdf via email to your section leader by 12:00PM on Wednesday, March 31st 2010. You cannot start on your final project until you get approval from your section leader, so the earlier you submit it and get approval the earlier you can begin working. Lastly, please submit your proposals in PDF format to eliminate chances of any problems when trying to read them.



  • You commented all functions thoroughly, including parameters, return types, and side effects: 4
  • You submitted a final project proposal that covered all aspects mentioned in the specification: 4

Code Design:

  • You applied a modular design to your solution: 4
  • You took advantage of either built-in features or a 3rd party library to handle XML details: 2
  • Focused and clear functions (each function only does one thing): 4
  • Practicing good naming (using descriptive variable and function names): 4


  • Your code properly allows a user to play the animal game: 8
  • Your code can persist its “knowledge” to disk in XML form: 4
  • Your code can load its “knowledge” from disk in XML form: 4


  • You committed your code on time and to the correct location in subversion: 4
  • You were able to give solid reasoning for all of your design decisions and explain to your section how your implementation functions: 4
  • In section, you made thoughtful questions or comments for each participant: 2
Document generated by Confluence on Feb 22, 2012 18:15

  1. No comments yet.

  1. No trackbacks yet.