CS 230 Fall 2009                                               

Assignment 8 – Procedures/Functions and More Looping and Branching – Craps!

100 Assignment Points

 

Assigned: 11/02/2009

Due: 11/09/2009 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. Read through the whole assignment; hints and details are spelled out throughout. Plan out tasks, objects, and events needed for program.  Think about the main function’s  pseudocode / flow chart.

 

Main Assignment Description:

We’re going to implement a simplified “craps” game. We will only use one of the many kinds of bets that can be made in craps – see below. Provide the capability to:

·        Play one game

·        Play a bunch of games without user intervention

·        Reset – clearing the results to start again

·        Exit

Show how each game goes (details) in a rich text box. Keep a running tally of wins and losses in text boxes (read-only of course) or labels.

Please set the name of the project to something other than the default name (WindowsApplication1, …). It is helpful if you use a name that identifies you as well as the assignment (e.g. yourlastname assignment 7).

 

Background Knowledge:

·         The form of craps we are playing goes by the following rules:

Roll

·         7 or 11 wins

·         2,3, or 12 loses

·         Anything else – becomes “point” – new target – keep rolling

After that

·         7 – loses (NOW, 7 is BAD)

·         “Point” – wins

·         Anything else – keep rolling (does NOT change “point”)

Any questions, please ask!!! Even if you’ve played different variations, the above is what we’re playing here.

 

Task Details:

Public Class Form1

    Dim randGen As New Random

It is recommended that the validation be done via calling a function!

·         This assignment is intentionally designed to reward use of procedures/functions – playing a game is basically the same in playing one game or in playing a bunch of games. Write a function  that can be called from each!  This is required as the #1 focus of this assignment is on functions. Doing this will also avoid the need to use nested loops!

·         HINT # 1: anything that needs to happen in one and not the other probably shouldn’t be in the procedure/ function.

·         HINT #2: return a Boolean indicating if the player won or not – this will allow the Play one game caller to display a message while the play a bunch of games doesn’t display a message (which would be very annoying if you played 1000 games)

·         HINT #3: you might try writing the code for “Play One Game”, then when that works move it into a function and make it work for both “Play One” and “Play Bunch”

 

Miscellaneous:

 

Hand in: