Advertisement
Guest User

Simon 2019

a guest
Nov 15th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4. #include <string>
  5. #include <unistd.h>
  6. using namespace std;
  7.  
  8. void ColorBoard(char color) {        //input for display will be an array, translating into a number 0-3
  9.     if (color == 'G') {
  10.         cout << "___________________________________" << endl;
  11.         cout << "_                _                _" << endl;
  12.         cout << "_     GGGG       _                _" << endl;
  13.         cout << "_    G    G      _                _" << endl;
  14.         cout << "_   G            _                _" << endl;
  15.         cout << "_   G   GGGG     _                _" << endl;
  16.         cout << "_   G     GG     _                _" << endl;
  17.         cout << "_    G     G     _                _" << endl;
  18.         cout << "_      GGGG      _                _" << endl;
  19.         cout << "_                _                _" << endl;
  20.         cout << "___________________________________" << endl;
  21.         cout << "_                _                _" << endl;
  22.         cout << "_                _                _" << endl;
  23.         cout << "_                _                _" << endl;
  24.         cout << "_                _                _" << endl;
  25.         cout << "_                _                _" << endl;
  26.         cout << "_                _                _" << endl;
  27.         cout << "_                _                _" << endl;
  28.         cout << "_                _                _" << endl;
  29.         cout << "_                _                _" << endl;
  30.         cout << "___________________________________" << endl;
  31.     }
  32.     else if (color == 'R') {
  33.         cout << "___________________________________" << endl;
  34.         cout << "_                _                _" << endl;
  35.         cout << "_                _     RRRR       _" << endl;
  36.         cout << "_                _     R   R      _" << endl;
  37.         cout << "_                _     R   R      _" << endl;
  38.         cout << "_                _     RRRR       _" << endl;
  39.         cout << "_                _     RR         _" << endl;
  40.         cout << "_                _     R R        _" << endl;
  41.         cout << "_                _     R  R       _" << endl;
  42.         cout << "_                _                _" << endl;
  43.         cout << "___________________________________" << endl;
  44.         cout << "_                _                _" << endl;
  45.         cout << "_                _                _" << endl;
  46.         cout << "_                _                _" << endl;
  47.         cout << "_                _                _" << endl;
  48.         cout << "_                _                _" << endl;
  49.         cout << "_                _                _" << endl;
  50.         cout << "_                _                _" << endl;
  51.         cout << "_                _                _" << endl;
  52.         cout << "_                _                _" << endl;
  53.         cout << "___________________________________" << endl;
  54.     }
  55.     else if (color == 'Y') {
  56.         cout << "___________________________________" << endl;
  57.         cout << "_                _                _" << endl;
  58.         cout << "_                _                _" << endl;
  59.         cout << "_                _                _" << endl;
  60.         cout << "_                _                _" << endl;
  61.         cout << "_                _                _" << endl;
  62.         cout << "_                _                _" << endl;
  63.         cout << "_                _                _" << endl;
  64.         cout << "_                _                _" << endl;
  65.         cout << "_                _                _" << endl;
  66.         cout << "___________________________________" << endl;
  67.         cout << "_                _                _" << endl;
  68.         cout << "_   Y       Y    _                _" << endl;
  69.         cout << "_    Y     Y     _                _" << endl;
  70.         cout << "_     Y   Y      _                _" << endl;
  71.         cout << "_      YYY       _                _" << endl;
  72.         cout << "_       Y        _                _" << endl;
  73.         cout << "_       Y        _                _" << endl;
  74.         cout << "_       Y        _                _" << endl;
  75.         cout << "_                _                _" << endl;
  76.         cout << "___________________________________" << endl;
  77.     }
  78.     else if (color == 'B') {
  79.         cout << "___________________________________" << endl;
  80.         cout << "_                _                _" << endl;
  81.         cout << "_                _                _" << endl;
  82.         cout << "_                _                _" << endl;
  83.         cout << "_                _                _" << endl;
  84.         cout << "_                _                _" << endl;
  85.         cout << "_                _                _" << endl;
  86.         cout << "_                _                _" << endl;
  87.         cout << "_                _                _" << endl;
  88.         cout << "_                _                _" << endl;
  89.         cout << "___________________________________" << endl;
  90.         cout << "_                _                _" << endl;
  91.         cout << "_                _     BBBB       _" << endl;
  92.         cout << "_                _     B   B      _" << endl;
  93.         cout << "_                _     B   B      _" << endl;
  94.         cout << "_                _     BBBB       _" << endl;
  95.         cout << "_                _     B   B      _" << endl;
  96.         cout << "_                _     B   B      _" << endl;
  97.         cout << "_                _     BBBB       _" << endl;
  98.         cout << "_                _                _" << endl;
  99.         cout << "___________________________________" << endl;
  100.     }
  101. }
  102.  
  103. //next part is used between each display and at the end, just a blank board cout statement
  104.  
  105. void BlankBoard () {
  106.     cout << "___________________________________" << endl;
  107.     cout << "_                _                _" << endl;
  108.     cout << "_                _                _" << endl;
  109.     cout << "_                _                _" << endl;
  110.     cout << "_                _                _" << endl;
  111.     cout << "_                _                _" << endl;
  112.     cout << "_                _                _" << endl;
  113.     cout << "_                _                _" << endl;
  114.     cout << "_                _                _" << endl;
  115.     cout << "_                _                _" << endl;
  116.     cout << "___________________________________" << endl;
  117.     cout << "_                _                _" << endl;
  118.     cout << "_                _                _" << endl;
  119.     cout << "_                _                _" << endl;
  120.     cout << "_                _                _" << endl;
  121.     cout << "_                _                _" << endl;
  122.     cout << "_                _                _" << endl;
  123.     cout << "_                _                _" << endl;
  124.     cout << "_                _                _" << endl;
  125.     cout << "_                _                _" << endl;
  126.     cout << "___________________________________" << endl;
  127. }
  128.  
  129. int main()
  130. {
  131.     char userInput[50];
  132.     char sequence[50];
  133.     int numRound = 1;
  134.     char color[4] = {'G', 'R', 'Y', 'B'};
  135.     bool status = true;
  136.     int currentColor;
  137.     int temp;
  138.     char userDiff;
  139.  
  140.     srand(time(NULL));          //colors: 0=G 1=R 2=Y 3=B
  141.     for(int i = 0; i <= 50; ++i){
  142.         sequence[i] = (color[rand() % 3]);
  143.     }
  144.    
  145.     do {
  146.     for (int i = 1; i <= numRound; ++i) {           //initial cout statements
  147.         ColorBoard(sequence[i]);
  148.         BlankBoard();
  149.         temp = i;
  150.     }
  151.     numRound = temp;
  152.     cout << "Please enter in the character sequence you observed on the screen" << endl;
  153.     cin >> userInput[numRound];
  154.     //took off ++numRound
  155.     if(sequence[numRound] != userInput[numRound]) {
  156.         cout << "Sorry the combination was not correct your final score is " << numRound - 1 << endl;
  157.         cout << "Game Over!";
  158.         status = false;
  159.     }
  160.     ++numRound;
  161.     }while(status == true);
  162.  
  163.     return 0;
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement