/* This plays the game “rock, scissors, paper, lizard, Spock”, but has half the if statements in the CodeAcademy example.
*/
#include
#include <stdlib.h>
#include
int main() {
//live long and prosper
int user = 0;
while (user != 6) {
srand (time(NULL));
int computer = rand() % 3 + 1;
std::cout << "\n\n\n Want to play rock, paper, scissors, lizard, spock?\n";
std::cout << "rock = 1\n";
std::cout << "paper = 2\n";
std::cout << "scissors = 3\n";
std::cout << "Spock = 4\n"; //Sheldon's logic requires Spock to be 4 instead of 5.
std::cout << "lizard = 5\n";
std::cout << "quit = 6\n";
std::cout << "shoot! ";
std::cin >> user;
if (user == 6) {
std::cout << "\n\n GOODBYE! ";
break;
};
std::cout << "\n The user chose " + std::to_string(user);
std::cout << "\n The computer chose " + std::to_string(computer);
std::cout << ("\n user: " + std::to_string(user)
+ " computer: " + std::to_string(computer));
if ((user < 1) || (user > 5)) {
std::cout << " Invalid Response\n";
} else if (user == computer) {
std::cout << " It's a tie!\n";
} else if (user > computer) {
if ((user % 2) == (computer % 2)) {
std::cout << " You lose. :(\n";
} else {
std::cout << " You win! :)\n";
}
} else if((user % 2) == (computer % 2)) {
std::cout << " You win! :(\n";
} else {
std::cout << " You lose. :)\n";
} // end primary if
} // end while loop
} // end function