Rock Paper Scissors Lizard Spock

Hi, I’m trying to write out the RPSLS game in a “Full Game” sort of way with nice text etc, I may have missed the point of the logic, but it’ll look nice.

https://www.codecademy.com/courses/learn-c-plus-plus/projects/rock-paper-scissors-lizard-spock

I’m trying to use the logic below but keep hitting an error:

std::cout << “================\n” << “Rock, Paper, Scisors, Lizard, Spock \n” << “+++++++++++++++++++\n”;

std::cout << “Rock = 1\n”;
std::cout << “Paper = 2\n”;
std::cout << “Scissors = 3\n”;
std::cout << “Lizard = 4\n”;
std::cout << “Spock = 5\n”;

std::cout << “Your Move!”;
std::cin >> user;

if (user = 1) && (computer = 3) || (computer = 4) {
if (computer = 3) {
std::cout “You chose Rock/n”
std::cout “Computer chose Scissors/n”
std::cout “Rock beats Scissors - Congratulations!\n”
}
else if (computer = 4) {
std::cout “You chose Rock/n”;
std::cout “Computer chose Lizard/n”
std::cout “Rock squashes Lizard - Congratulations!\n”
}

  }
 else if (user = 1) && (computer = 1) || (computer = 2) || (computer = 5) {
 if (computer = Rock) {
  std::cout "You chose Rock/n"
  std::cout "Computer chose Rock/n"
  std::cout "Rock ties with Rock - Draw!\n"
  }
 else if (computer = 2) {
  std::cout "You chose Rock/n";
  std::cout "Computer chose Paper/n"
  std::cout "Paper wraps Rock - Loser!\n"
  }
 else if (computer = 5) {
  std::cout "You chose Rock/n";
  std::cout "Computer chose Paper/n"
  std::cout "Spock disintigrates Rock - Loser!\n"
  }
 }

}

Error: expected identifier before “(” @ (computer=1 . . . etc

Any ideas what’s not right here?

= is not a conditional operator. You also have to have all your conditionals in a parenthesis. The Composite Conditions section is something you should look over. Also where are you declaring user and computer? Are you giving computer a random integer?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.