Feature Complete?
This commit is contained in:
parent
253a2daeac
commit
df6e679963
@ -32,21 +32,21 @@ std::vector<std::string> generateSecretCode(int digits, int optionsPerDigit) {
|
|||||||
std::vector<std::string> secretCode;
|
std::vector<std::string> secretCode;
|
||||||
|
|
||||||
for (int i = 0; i < digits; i++) {
|
for (int i = 0; i < digits; i++) {
|
||||||
int digit = getRandomNumberInRange(0, optionsPerDigit);
|
int digit = getRandomNumberInRange(1, optionsPerDigit);
|
||||||
secretCode.push_back(std::to_string(digit));
|
secretCode.push_back(std::to_string(digit));
|
||||||
std::cout << "Secret Code was set as " << digit << std::endl;
|
// std::cout << "Secret Code was set as " << digit << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return secretCode;
|
return secretCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> getCodeGuessFromConsole() {
|
std::vector<std::string> getCodeGuessFromConsole(int codeLength) {
|
||||||
std::cout << "Have a Guess!" << std::endl;
|
std::cout << "Have a Guess!" << std::endl;
|
||||||
|
|
||||||
std::vector<std::string> guess;
|
std::vector<std::string> guess;
|
||||||
|
|
||||||
// TODO Make limit dynamic
|
// TODO Make limit dynamic
|
||||||
for (int i = 1; i < 5; ++i) {
|
for (int i = 1; i <= codeLength; ++i) {
|
||||||
// std::cout << "Enter Digit " << i << " : " << std::endl;
|
// std::cout << "Enter Digit " << i << " : " << std::endl;
|
||||||
std::string input;
|
std::string input;
|
||||||
std::cin >> input;
|
std::cin >> input;
|
||||||
@ -103,21 +103,37 @@ int countMatches(std::vector<std::string> &v1, std::vector<std::string> &v2) {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Aufg5Main() {
|
void Aufg5Main() {
|
||||||
// generateSecretCode(1,1);
|
int optionsPerDigit = 4;
|
||||||
|
int codeLength = 4;
|
||||||
|
int livesRemaining = 5;
|
||||||
|
std::cout << optionsPerDigit << " options per Digit" << std::endl;
|
||||||
|
std::cout << codeLength << " Code Length" << std::endl;
|
||||||
|
std::cout << livesRemaining << " Lives Remaining" << std::endl;
|
||||||
|
std::vector<std::string> SecretCode = generateSecretCode(codeLength, optionsPerDigit);
|
||||||
|
|
||||||
std::vector<std::string> SecretCode = generateSecretCode(4, 4);
|
std::cout << "I have locked the door with a secret Code, you will never be able to figure it out!!" << std::endl;
|
||||||
|
// printAllStringsInVector(SecretCode);
|
||||||
|
|
||||||
|
int perfectCounter = 1;
|
||||||
|
while (perfectCounter && livesRemaining) {
|
||||||
|
std::vector<std::string> guess = getCodeGuessFromConsole(codeLength);
|
||||||
|
|
||||||
|
perfectCounter = countPefectMatches(guess, SecretCode);
|
||||||
|
|
||||||
|
std::cout << "correct were: " << countMatches(guess, SecretCode) << std::endl;
|
||||||
|
std::cout << "perfect were: " << perfectCounter << std::endl;
|
||||||
|
|
||||||
|
livesRemaining--;
|
||||||
|
|
||||||
|
if (perfectCounter == codeLength) {
|
||||||
|
std::cout << "No! This cant be!" << std::endl << "How did you know???" << std::endl << "What kind of Computer Nerd are you?!?";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "You Lost!" << std::endl << "My Secret Code stays a Mystery!!!" << std::endl << std::endl << "Fine, I will tell you" << std::endl;
|
||||||
printAllStringsInVector(SecretCode);
|
printAllStringsInVector(SecretCode);
|
||||||
|
std::cout << "NERD ㄟ(≧◇≦)ㄏ";
|
||||||
std::vector<std::string> guess = getCodeGuessFromConsole();
|
|
||||||
std::cout << "correct were: " << countMatches(guess, SecretCode) << std::endl;
|
|
||||||
std::cout << "perfect were: " << countPefectMatches(guess, SecretCode) << std::endl;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user