-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRockPapperScissor.cpp
65 lines (52 loc) · 1.74 KB
/
RockPapperScissor.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include<iostream>
#include <cctype>
using std::cout;
using std::string;
using std::cin;
using std::endl;
void lowerFunc(string str) ;
void playerChoice(char choice);
char computerChoice();
char showChoice(char choice);
void ShowWinner();
int main( ){
string str ;
char choice;
char choice1;
// // cout<<"Enter The Text\n";
// // getline(cin>>std::ws, str);
// lowerFunc(str);
choice1 = showChoice(choice);
playerChoice(choice1);
return 0;
}
void playerChoice(char choice){
// char choice;
switch(choice){
case 'r': cout<<"You Choose -= Rock =- ";
break;
case 's': cout<<"You Choose -= Sicssor =- ";
break;
case 'p': cout<<"You Choose -= Paper =- ";
break;
}
}
char showChoice(char choice){
do{
cout<<"Enter Choice\n";
cin>>choice;
choice = tolower(choice);
cout<<" = Rock - Paper - Sicssor";
cout<<"\n ------======--------\n";
cout<<"Choose Among this \n = R= | = P= | = S = \n";
}while(choice != 'r' && choice!= 's' && choice!= 'p');
return choice;
}
void lowerFunc(string str){ // str will take input
int length = str.length(); // take length of string as dynamic
for (int i = 0 ;i < length; i++ ){ // Alwasy specify i=0 dont leave blank or it will not consider start if in function
int convert = str[i]; // take str array and convert the element to lower
str[i] = tolower(convert);
}
cout<< str;
}