CS 230 Spring 2007
Assignment 5 – Looping (Paparazzi Invasion Silly
Simulation Game)
100 points
Assigned: 02/21/2007
Due: 02/28/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. If you didn’t get an A on the midterm, write pseudocode for
the main button (and even if you did get an A, it’s probably worthwhile).
Main Assignment:
You are
creating an extremely simplified simulation “game” (I use quotes because it is
so simplified). Write a program that simulates the invasion by paparazzi with
no defense against them. Get from the user the starting number of paparazzi,
difficulty level (1-10), and the number of months to simulate. Display in a
RichTextBox (see below) for each month elapsed, the number of months elapsed to
that point and the number of paparazzi that have invaded. After the given
number of months, display in labels or read-only textboxes the final number of
paparazzi. NOTE – this task MUST be done with a loop – I need to see the month
by month results in the text box – and in order to see that, you cannot do a
single one-time calculation.
·
Provide capabilities
to simulate, clear (the inputs and outputs) to start again, and to exit.
Hand in:
- Floppy disk or CD-R with an entire folder containing all
files related to the project. 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). Use Windows to copy the whole folder,
instead of trying to “Save As”.
- Print out of your code.
Task Details:
·
The number of new paparazzi invading each month is equal to 10
times the difficulty level (e.g. with a difficulty level of 7, 70 new pararazzi
would invade each month.
·
Sorry, in this simplified game, there is no way to get rid of
paparazzi.
- Define numbers
(especially those that could change sometime in the futures) as named constants
- The number of
paparazzi and the difficulty level are always whole numbers
- We’re no longer going
to assume that the clerk enters valid and reasonable values. Ensure that
the starting number of paparazzi, difficulty level, and number of months
are numeric (and whole numbers for that matter), and that the starting number
of paparazzi is positive, the difficulty level is 1-10, and the number of
months is between 2 and 1000. Don’t try to calculate anything if bad data
has been entered (display a message).
- To add items to the
rich text box, use richtextboxname.AppendText( a string ). You can build a
string out of pieces using “concatenation” . E.g. “Month: “ &
month.toString() & ControlChars.NewLine
(The
ControlChars.NewLine moves the next info after to a new line). To clear the
contents of a list box, use richtextboxname.Clear()
- MAKE SURE YOUR PROGRAM
WORKS! (i.e. gets the correct answers). It doesn’t have to just run, it
needs to run correctly! It should run on any inputs (We are
now branching – so the program must be tested on more inputs to ensure
that all paths through the program code work!). For instance, does your
program still do the right thing no matter how many of the inputs are
invalid?
Miscellaneous
- You must turn on
Option Explicit and Option Strict.
- 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.
- Remember to use
meaningful variable names, and indent to show the structure of the program
(VB usually does this correctly).
- Name all textboxes and
buttons and the rich text box meaningfully, and use conventions for
starting their names.
- Make textboxes that
user should never enter a value in (results / outputs) “Read Only”
- 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. Make error messages as clear and helpful as possible!