Professor Simonson

How Computers Work

CSC 195

In Class Assignment - Designing a Program with a GUI

Due Before Spring Break

25 Points

This program should be done primarily in class, but you will likely need to work on it outside of class in order to complete it on time.  You will write a program to let a child practice reading dice correctly.  You should display two dice randomly chosen at the top of the screen, with a choice of boxes 2 through 12 underneath.  The child clicks on a box, gets a response whether she is correct or not, and two new dice are displayed.  After ten questions, a summary of how many the child got correct is printed on a new screen, and two boxes marked play_again and quit are displayed.  The child then chooses whether to continue playing or not by clicking in the appropriate box.

This program will teach you how to put all the basics you have learned together into a large program.  You should learn how to use parameters, design in a top-down clear manner, and use graphical user interfaces.

Here is an outline of the top procedure.

To inclass_dice

make "num_games 0;  data structures to keep total average score
make "total_correct 0

play_the_game ; This is where you have to do all your work.
       ;  This procedure tests the kid 10 times, keeps track of how many the kid gets correct,
       ;  prints out appropriate messages and summaries of the scores so far.
       ;  It is similar in function to the odd-even program "quiz"

Inside play_the_game you will need a play again section consisting of:

    ; draws a box with the word "play_again" in it
    ; draws a box with the word "quit" in it
if (= getanswer "quit) then final_message stop

    ; getanswer returns "quit if the person clicks in the "quit" box, and "play if the person clicks in "play again"
    ;  final_message makes a final report to the kid inclass_dice


Strategies, hints, and good style will be discussed in class both in general and one on one in individual groups.