CS 230 Spring 2007          Assignment 8 & 9 – More Sub Procedures and Function Procedures and Files–

(Paparazzi Invasion II – Celebrity Revenge Silly Simulation Game)                        200 points

 

Assigned: 03/21/2007

Due: 04/04/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 buttons and for functions / independent sub procedures. There’s a lot here, take it on bit by bit, as recommended in class.

.

Main Assignment:

You are creating a simplified but improved simulation “game”.  You are now more powerful, and so are the celebrities subject to the paparazzi invasion!  

·         Write a program that simulates the invasion by paparazzi with the player allowed to choose a defense against them. 

·         Upon loading the form (Form Load Event), randomly generate the effectiveness of each of 5 possible defenses against the paparazzi (do this using a independent sub procedure called from the Form Load Event Handling Procedure for reasons that will become clear below).

·         For the Simulate button - Get from the user the starting number of paparazzi, difficulty level (1-10, combo box recommended), defense of choice (combobox recommended), and the number of months to simulate. Make sure that input values are all validated as described below (do this using an independent function procedure called from the button handling procedure).

·         Display in a RichTextBox (see below) for each month elapsed, the number of months elapsed to that point, the number of new paparazzi, the number of paparazzi eliminated and the resulting number of invading paparazzi.  

·         After the given number of months, display in labels or read-only textboxes the final number of paparazzi. Also, update the textbox for starting number of paparazzi (so the player can continue the game if they like), and make it read-only. 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:

o        simulate,

o        clear (the inputs and outputs) to start again, and set the difficulty level to default (5), set the current month back to the beginning, and make the starting number of paparazzi text box no longer read only.

o        restart (clearing inputs and outputs etc, as above, AND redo the random number generation for defense effectiveness)

o        exit.

·         A sample interface is provided on page 3. Don’t let that constrain your creativity. Use it to help understand what I see as the inputs and outputs.

·         A surprise “twist” to the project related to files will be added to the requirements on 3/28. Stay tuned! (Hence the Assignment 8 AND 9)

Hand in:

Task Details:

·         In this task, we will get several of the benefits of procedures and functions (some will be called from more than one place, saving code; dividing a task up into manageable sub-tasks, making the whole easier than the sum of the tasks, and hopefully being able to re-use existing code).  You must write procedures and functions for this assignment (and use them!):

·         Random generation of effectiveness of defenses must be handled by a function (hopefully called 5 times instead of once) (for details on the effectiveness, see below)

·         Determining how many new paparazzi will invade each month could be handled by a function (recommended). (for details on the invasion, see below)

·         Determining effectiveness of currently chosen defense could be handled by a function (recommended) . Use of module scope variables is ok, since effectiveness will be determined by another button and/or form load.

·         Validating inputs must be handled by a function(s) (preferably one function, called more than one time)   

·         You must use an independent sub procedure to clear textboxes etc for clear and restart capabilities

 

Miscellaneous