Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
PineapplePen/memorygame.cpp
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
34 lines (28 sloc)
840 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "memorygame.h" | |
using namespace std; | |
string sequence; | |
int randomsequence() | |
{ | |
char full_alpha[27] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; | |
cout << "You have 10 seconds to memorise the following list of words!" << endl; | |
for (int i = 0; i < 6; i++) | |
{ | |
string c; | |
int random_number = rand() % 26; // generate a random number | |
c = 'a' + random_number; // Convert to a character from a-z | |
sequence += c; | |
} | |
cout << sequence << endl; | |
return 0; | |
} | |
void memorycheck(string &answer) | |
{ | |
if (sequence == answer) | |
{ | |
cout << "Well done! You have cooked a great meal! 20 pounds has been added to your account." << endl; | |
} | |
else if (sequence != answer) | |
{ | |
cout << "Oh no! You have burnt all the food! This will be deducted from your wages." << endl; | |
} | |
} |