CS 230 Spring 2007          Assignment 7 – Sub Procedures and Function Procedures                                       100 points

 

Assigned: 03/14/2007

Due: 03/21/2007 at the start of class

 

Pre-Lab (Do Before Lab):  Bring materials – a way to save a copy for you and a copy to turn in. Plan out tasks, objects, and events needed for program. Write pseudocode for the main button and for functions / independent sub procedures

.

Main Assignment:

Casinos are coming to the Philadelphia area!  Imagine that you are writing the beginnings of a very basic program for a dice game.  This time the user is allowed to win!  The first time playing, the user will enter into a textbox how many “points” they have to start. They will also enter (each time they want to play) a guess for the total for all rolled dice. When a “Roll” button is Clicked, the program should (do this in a function!) generate a random number of rolls between 10 and 20, and roll a die that many times, keeping track of the total.  If the player’s guess is below (or equal) the total of the rolled dice, they win the number of points that they guessed.  If the players guess is greater than the total of the rolled dice, they lose the number of points that they guessed.  After the roll has been completed, display in labels or read-only textboxes the number of rolls, and the total, and the user’s result (how much they won or lost), along with updating the users current balance of points.   

·         Provide capabilities to play, clear (the inputs and outputs except the user’s balance), reset (to start over again – clear the balance too and make it no longer read-only), and to exit.

Hand in:

Task Details:

·         In this task, we mainly only get one of the benefits of procedures and functions (dividing up into manageable tasks). Most procedures or functions you would write will only be called from one place in your code. However, you must write some procedures and functions for this assignment (and use them!)

o        The rolling of dice must be handled by a function

o        Determining if the user wins or loses (and how much) should be handled by a function

o        If we have covered validating inputs using a function on Wed, then you need to do that (otherwise it is optional)

o        Use a independent sub procedure to clear textboxes for clear and reset capabilities

Miscellaneous