CS 230 Fall 2009 Assignment
5 –Random Number Generation and MultiWay Branching
100 points
Assigned: 10/06/2009
Due: 10/12/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. Plan out tasks, objects, and events
needed for program. Think about the main button’s pseudocode / flow chart.
Main Assignment:
The Food! Casino
offers pseudo-slot machines in which the machine displays one of the following
5 images:
·
Pizza – wins and pays 1.5 to 1 (or 3:2) if you prefer
·
Choc chip cookies – wins and pays even money
·
Coffee – loses
·
Cake – loses
·
Deli sandwich – loses
The Casino has
asked you to develop a program to produce a video version. You will need to get
from the user the amount bet. You will then randomly generate one of the five
images to display, and adjust the player’s current stake (amount of money). As
a simplifying assumption, all gamblers start with $100.00 of money. In addition to the betting capability, provide
capabilities to reset (sets amount of money back to $100 and clears the bet
text box) to start again, and to exit.
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 5).
Background Knowledge:
- When the gambler
loses, their amount of money is reduced by the amount of their bet
- When a gambler wins “even
money”, their amount of money is increased by the amount of their bet
- When a gambler wins
1.5 to 1, the winnings are 1.5 times their bet (e.g. if they bet $10 and
hit the pizza jackpot, their amount of money is increased by $15
Task Details:
- The images are
provided in Blackboard. These public domain images have pretty obvious
names.
- Include 5 picture
boxes with the possible images – showing payoff for each. Click on the
arrow on the picture box to import the image into the project, specify the
image and that the “Size mode” should be “Zoom”.
- The picture box that
displays the image generated by the slot machine when the gambler bets can
be filled using an assignment from one of the other picture boxes. E.g.
slotPictureBox.Image = pizzaPictureBox.Image (if those are the
names you used)
- Don’t format the
amount of money as currency as that will make conversion difficult (put a
$ as a label in front of the textbox)
- We’re no longer going
to assume that the user enters valid and reasonable values, so ensure that
the bet entered is a number, and that it is legal – let’s assume that the
bet has to be positive and no more than the amount of money they currently
have.
- MAKE SURE YOUR PROGRAM
WORKS! (i.e. gets the correct answers) - it doesn’t have to just run, it
needs to run correctly! Now that our program is branching, we
need to try more examples to make sure that they work. Think, “what
different possibilities need to be checked?” For each, determine the
correct answer by hand and see if your program gets it!.
Miscellaneous:
- You must turn on
Option Strict and Option Explicit
- Put YOUR NAME, e-mail
address, date, and purpose of the program in comments at the beginning of
the program. The purpose should be what the program is supposed to do, not
the learning goals. Comments are indicated with a single quote (everything
after the single quote is only for humans)
- You MUST include
comments that explain your program in order to get full credit.
- Name all textboxes and
buttons meaningfully, and use conventions for ending their names. Also,
any labels referred to in code should also be named meaningfully.
- Make any textboxes
that user should never enter a value in “Read Only” (or use labels
instead!)
- Any variables that you
declare should have meaningful names – descriptive of the data that they
hold.
- Put your name on
the form as a Label or as part of the form title.
- Try to use good user
interface design. Make clear what user needs to do and what the answers
mean.
- Any label controls used
for results will be easier to find and click on etc if you turn the
AutoSize property to false and size it yourself.
Hand in:
- Compressed (zipped) folder with your entire project containing
all files related to the project, submitted to Blackboard. Please
name the zip file something along the lines of yournameAssignment5
- Print out of your code.