Contents

Overview

In this PA, you will extend your PA1 so that it's bigger and better. You will add three new features: new scenes to make your game more interesting, loops to help deal with bad input from users, and functions to help organize and modularize your code. PA2 will be broken into three milestones, as listed below.

At the start of this PA, you don't know what functions are—that's okay, that part won't be due until milestone 3.

(Back to top)

Specifications

Your completed submission must have at least the following components (you're welcome to add additional features to the game!):

(Back to top)

Milestones

Milestone 1: Extra Scenes

Update your code to include at least three more scenes from your original design from PA1.1. Note that your if statements will become nested, meaning you'll have if's inside of if's inside of if's. That'll look messy, but we'll have it all cleaned up and looking nice by the end of PA2.3.

Before your write your code, be sure to write the pseudo code. I'll look for the pseudo code comments and points will be deducted if they are missing. Implemented it in an incremental fashion and make sure the final version compiles and runs.

Submit your .cpp file to here. You can view the rubric here.

Milestone 2: Loops and Function design

This milestone consists of two advances. First, update your code so that inputs from the user are validated. That means, if you prompt the user to enter a 1 or 2 (for choice 1 vs. choice 2), making sure they entered a 1 or a 2, and not something other than that. You should use some sort of loop for this so that the user is continually re-prompted until they enter a valid option. As you are crafting to code to do this, think about the following questions:

Make sure to test your validation for one scene and ensure your code works before implementing similar validation loops for your other scenes.

The second part of this milestone is to think about function design. First, think about what functions you would like. According to the specs above, at least six should contain code to display scenes and prompt users for the option. What could the other three non-main functions be? Think about code that is repeated in your code that could be easily abstracted into a function. This code doesn't have to be identical in every place that its used, but it should be parameterizable (just like the formula m×x+b is parameterized by the inputs m, x, and b).

Next, think about what data needs to pass into and out of a function. What parameters should each functions should take? Should they be pass-by-value or pass-by-reference? What the return type of the function will be? Any variables use inside of a function, but whose value is assigned outside of the function needs to be passed in. In addition, any value that is computed inside of a function that is needed outside of that function needs to be passed into the function as a pass-by-reference variable or as a return value.

For every function you will have in your final submission except for main (so, at least 9 functions), you will need to include a function declaration above main and a function definition stub below main. You do not need to have any code inside of your function stubs, other than to return dummy values for functions with non-void return types. Be sure to include a function comment above each stub that describes what it does and what parameters it takes.

You code should compile at the end even though the functions are not fully defined yet.

Submit your .cpp file here. You can view the rubric here.

Milestone 3: Completed assignment

Complete your program in an incremental fashion: consider one function stub at a time. For that stub, implement the body either by moving existing code into the function or implementing it from scratch. Ensure that it compiles and runs after each function you implement. Before moving on to the next function, replace the code in main with an invocation of the function you just implemented.

Submit your .cpp file here. You can view the rubric here (it's a different rubric from the previous milestones).

(Back to top)