Project
(PROJECT) Assignment Instructions
Read and follow the directions below carefully and perform the steps in the order listed. You will be solving one program as instructed and turning in your work electronically via an uploaded file within Eagle Online. Make sure and check your work prior to uploading the assignment (Print this instruction sheet if needed).
Instructions
1. Using Visual Studio, or Xcode, create a new empty project in your working drive. Name the Project: ProjectLastFirst
(NOTE: where LastFirst is your actual Lastname and Firstname. For Example, if your name is Mary Smith then your empty project folder will be named ProjectSmithMary)
2. Keep the default filename for the source file: source.cpp in Visual Studio, or main.cpp in Xcode
(NOTE: If your filenames are incorrect, don’t try to rename them. Either start over or leave them as is)
3. You will develop a C++ game of your choice!
You can choose the game of your choice. Below is a list of possible games. CHOOSE ONE from the list provided. Don’t forget to read the requirements (steps 5,6,7 below):
· (Easy) Magic 8-ball :
o Prompt the user to enter a yes or no question (Will it rain? Will I make an A? etc…). o Read in the question using getline().
o Generate a random number between 0-7.
o Create an array of strings with 8 items. The 8 strings will all be yes/no type phrases (“Absolutely!!!”, “There is no way that will ever happen!”, etc…).
o Based on the random number, print out the position in the array.
o If you’re not sure what a magic 8-ball is, you can pick another project
· (Moderate) Tic/Tac/Toe: Have TWO users play against each other, which is easier than playing against the computer. You will want to use a 2-dimensional array to create a board.
· (Harder) Hangman
· (Harder) Memory
· (Harder) Battleship
4. If your game needs to generate a random number:
I like to use FIVE steps when trying to generate a random number. You will need two preprocessor directives at the top of your program, you will then need to declare/define a variable to hold the random number, then you will need two lines to actually create the number.
For example, to generate a random number between 0 and 9 (aka. 10 possible numbers), you will need the following code:
|
#include <cstdlib> |
//STEP 1 out of 5 |
for random numbers |
|||
|
#include <ctime> |
//STEP 2 |
of |
5 |
for random numbers |
|
|
int num; |
//STEP 3 |
of |
5 |
create var to store the random number |
|
|
srand(time(0)); |
//STEP |
4 |
of |
5 |
for random numbers |
|
|
|
|
|
|
|
|
num = rand() % 10; |
//STEP |
5 |
of |
5 |
for random numbers |
If you want to generate a random number between 0 and 99 (aka. 100 numbers), change STEP 5 to:
num = rand() % 100; //STEP 5 of 5 for random numbers
If you want to generate a random number between 1 and 100 (aka. 100 numbers), change STEP 5 to:
num = rand() % 100 + 1; //STEP 5 of 5 for random numbers
If you want to generate a random number between 0 and 7 (aka. 8 numbers), change STEP 5 to:
num = rand() % 8; //STEP 5 of 5 for random numbers
5. You must include comments!
6. It is imperative that your output looks professional! That is, no typos! Use capital letters at the beginning of a sentence or phrase. Use punctuation when appropriate. Make the output neat. ETC…
7. You must make your program modular. That is, you must use functions!!! For example, if you chose to create the Magic 8-ball , have a function to read in the number, have a function to create the random number perhaps, etc… Write your program using at LEAST 1 function, though 2 or more functions will be required for making the highest possible grade.