Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <cstdlib>
- #include <cmath>
- #include <string>
- using namespace std;
- void ColorBoard(int color) { //input for display will be an array, translating into a number 0-3
- static_cast<char>(color);
- if (color == 'G') {
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ GGGG _ _" << endl;
- cout << "_ G G _ _" << endl;
- cout << "_ G _ _" << endl;
- cout << "_ G GGGG _ _" << endl;
- cout << "_ G GG _ _" << endl;
- cout << "_ G G _ _" << endl;
- cout << "_ GGGG _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- }
- else if (color == 'R') {
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ RRRR _" << endl;
- cout << "_ _ R R _" << endl;
- cout << "_ _ R R _" << endl;
- cout << "_ _ RRRR _" << endl;
- cout << "_ _ RR _" << endl;
- cout << "_ _ R R _" << endl;
- cout << "_ _ R R _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- }
- else if (color == 'Y') {
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ Y Y _ _" << endl;
- cout << "_ Y Y _ _" << endl;
- cout << "_ Y Y _ _" << endl;
- cout << "_ YYY _ _" << endl;
- cout << "_ Y _ _" << endl;
- cout << "_ Y _ _" << endl;
- cout << "_ Y _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- }
- else if (color == 'B') {
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ BBBB _" << endl;
- cout << "_ _ B B _" << endl;
- cout << "_ _ B B _" << endl;
- cout << "_ _ BBBB _" << endl;
- cout << "_ _ B B _" << endl;
- cout << "_ _ B B _" << endl;
- cout << "_ _ BBBB _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- }
- }
- //next part is used between each display and at the end, just a blank board cout statement
- void BlankBoard () {
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "_ _ _" << endl;
- cout << "___________________________________" << endl;
- }
- int main()
- {
- string userInput = "";
- string sequence = "";
- int numRound = 1;
- int color[4] = {'G', 'R', 'Y', 'B'};
- bool status;
- int currentColor;
- int temp;
- srand(time(NULL));
- //colors: 0=G 1=R 2=Y 3=B
- do {
- sequence += static_cast<int>(color[rand() % 3]);
- currentColor = color[rand() % 3];
- for (int i = 1; i <= numRound; ++i) { //initial cout statements
- ColorBoard(currentColor);
- BlankBoard();
- temp = i;
- }
- numRound = temp;
- cout << "Please enter in the character sequence you observed on the screen" << endl;
- cin >> userInput;
- //took off ++numRound
- if(sequence != userInput) {
- cout << "You made it to round " << numRound - 1 << endl;
- cout << "Game Over!";
- status = false;
- }
- }while(status == true);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement