Hey, im back again. I got a little time to program and so i decided to write a rock paper scissors program.
I am not sure what is wrong with it but it closes after the user inputs somthing. I think i needs it to return a value
Code:
#include <cstdlib>
#include <iostream>
using namespace std;
int rock();
int paper();
int scissors();
int main()
{
int select;
cout<< "Welcome to Rock, Paper, Scissiors Version 1.0";
cout<< "\nInstructions:\n";
cout<< "\nType ( 1 ) to cast rock\n";
cout<< "Type ( 2 ) to cast paper\n";
cout<< "Type ( 3 ) to cast paper\n";
cout<< "\nYour choice : ";
cin>> select;
switch (select)
{
case 1:
rock();
break;
case 2:
cout<<"asdf";//paper();
break;
case 3:
cout<<"ahrt";//scissors();
break;
default:
cout<< "\nThat was not a selection!\n";
break;
}
cin.get();
}
int rock()
{
int compchoicerock;
compchoicerock = rand() % 3 + 1;
if ( compchoicerock == 1 ){
cout<< "\nThe computer also chooses rock.\n";
cout<< "The round ends in a draw.";
}
else if( compchoicerock == 2 ){
cout<< "\nThe computer chooses paper, and paper covers rock so you lose!\n";
}
else if( compchoicerock == 3 ){
cout<< "\nThe computer chooses scissors, rock smashes scissors so you win!";
}
}