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

Update RPS.cpp #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 99 additions & 82 deletions 3-conditionals-and-logic/rock-paper-scissors-lizard-spock/RPS.cpp
Original file line number Diff line number Diff line change
@@ -1,98 +1,115 @@
/*
Program challenge C++ in Rock, Paper, Scissors

Describe program :
1. Prompt user to select either rock, paper, scissors, lizard, spock
2. instruct computer randomly select either Rock, Paper, Scissor, Lizard, Spock
4. Compare user choice and computer choice to determine who the winner
5. Inform user who the winner

Logic to game changing :
1. Scissors cuts Paper
2. Papers covers Rock
3. Rock crushed Lizard
4. Lizard poisons Spock
5. Spock smashes Scissors
6. Scissors decapite Lizard
7. Lizard eats Paper
8. Paper disproves Spock
9. Spock vaporizes Rock
10. Rock Crushes Scissor
*/

#include <iostream>
#include <cstdlib>
#include <stdlib.h>

int main() {
int main (){

// declare a random number
srand(time(NULL));

int computer = std::rand() % 3 + 1;

int user;

std::cout << "====================\n";
std::cout << "rock paper scissors!\n";
std::cout << "====================\n";

std::cout << "1) ✊\n";
std::cout << "2) ✋\n";
std::cout << "3) ✌️\n";

std::cout << "shoot! ";

std::cin >> user;

if (user == 1)
std::cout << "you choose: ✊\n";
else if (user == 2)
std::cout << "you choose: ✋\n";
else
std::cout << "you choose: ✌️\n";

if (computer == 1)
std::cout << "cpu choose: ✊\n";
else if (computer == 2)
std::cout << "cpu choose: ✋\n";
else
std::cout << "cpu choose: ✌️\n";


if (user == computer) {

std::cout << "it's a tie!\n";

// make random number 1,2,3 for computer
int computer_input = rand() % 3 + 1;
int user_input = 0;

// make output input program
std::cout << "===========================\n";
std::cout << "Game rock, paper, scissors, \n";
std::cout << "===========================\n";

std::cout << "Choose your Shoot : \n";
std::cout << "1) ✊ rock \n";
std::cout << "2) ✋ paper \n";
std::cout << "3) ✌ scissor \n";

std::cout << "Input Your shoot ! : ";
std::cin >> user_input;
std::cout << "\n";


// Make logic decision to view what is computer choice
std::cout << "=========================================\n";
std::cout << "The Computer Choice : ";
if (computer_input == 1){
std::cout << "1) ✊ rock \n";
} else if (computer_input == 2){
std::cout << "2) ✋ paper \n";
} else if (computer_input == 3){
std::cout << "3) ✌ scissor \n";
} else {
std::cout << "Error, Invalid type choice \n";
}

// user rock

else if (user == 1) {

if (computer == 2) {

std::cout << "you lost! booooo!\n";

}
if (computer == 3) {

std::cout << "you won! woohoo!\n";

}



// Make a logic decision to view what is user choice
std::cout << "The User Choice : ";
if (user_input == 1){
std::cout << "1) ✊ rock \n";
} else if (user_input == 2){
std::cout << "2) ✋ paper \n";
} else if (user_input == 3){
std::cout << "3) ✌ scissors \n";
} else {
std::cout << "Error, Invalid type choice \n";
}

// user paper

else if (user == 2) {

if (computer == 1) {

std::cout << "you won! woohoo!\n";

// Make a logic decision for rock, papper, scissors to determine who the winner
std::cout << "The Status Winner is : ";
if (computer_input == 1){
if (user_input == 1){
std::cout << "Equal (Seri) \n";
} else if (user_input == 2){
std::cout << "Human User \n";
} else if (user_input == 3){
std::cout << "Computer \n";
} else {
std::cout << "Error Invalid input From User \n";
}
if (computer == 3) {

std::cout << "you lost! boo!\n";

} else if (computer_input == 2){
if (user_input == 1){
std::cout << "Computer \n";
} else if (user_input == 2){
std::cout << "Equal (Seri) \n";
} else if (user_input == 3){
std::cout << "Human User";
} else {
std::cout << "Error Invalid input From User \n";
}

}

// user scissors

else if (user == 3) {

if (computer == 1) {

std::cout << "you won! woohoo!\n";

} else if (computer_input == 3){
if (user_input == 1){
std::cout << "Human User \n";
} else if (user_input == 2){
std::cout << "Computer \n";
} else if (user_input == 3){
std::cout << "Equal (Seri) \n";
} else {
std::cout << "Error Invalid Input From User \n";
}
if (computer == 2) {

std::cout << "you lost! booooo!\n";

}

} else {
std::cout << "Error Input Computer Randomly \n";
}

std::cout << "==========================================\n";
return 0;

}