Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simon says #19

Open
kc18babas opened this issue Sep 20, 2022 · 0 comments
Open

simon says #19

kc18babas opened this issue Sep 20, 2022 · 0 comments

Comments

@kc18babas
Copy link

#include // for I/O
#include // for strlen()
#include // for random numbers
#include <unistd.h> // for sleep()
#include "ZyLab.h" // for ZyLab Setup
using namespace std;

int main(int argc, char **argv) {

const int DEFAULT_NUMBER_OF_ROUNDS = 15;
int numRounds = DEFAULT_NUMBER_OF_ROUNDS;

// if a command line argument is given, use that string to init the
// "random" sequence and set the number of rounds to play the game
if (argc == 2) {
numRounds = strlen(argv[1]);
}

string s; // A string used to pause the game
char c; // The player's typed characters
char *seq = new char[numRounds]; // Sequence of numRounds colors to match
char colors[] = "RGBY"; // Allowable colors
bool lost = false; // Indicates whether we win or lose
int round; // Indicates the current round

// Initialize random number generator
srand(time(0));

// Determine the random color sequence using either argv[1] or
// randomly determined letters from 'R', 'G', 'B', and 'Y'
for (int j = 0; j < numRounds; j++) {
seq[j] = (argc == 2) ? argv[1][j] : colors[rand() % 4];
}

// Wait until the player is ready
cout << "Welcome to Simon, press enter to play .... ";
getline(cin, s, '\n');

/* Type your code here. */

return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant