-
Notifications
You must be signed in to change notification settings - Fork 24
Add score #35
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
Open
Elshamy-24
wants to merge
1
commit into
VickyTheRocker:main
Choose a base branch
from
Elshamy-24:edit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add score #35
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,109 +1,111 @@ | ||
| #include<iostream> | ||
| #include <iostream> | ||
| using namespace std; | ||
|
|
||
| int main() | ||
| { | ||
| int a[3] = {1, 2, 3}; | ||
| int w; | ||
| string b[3] = {"Rock", "Paper", "Scissor"}; | ||
| int uc, cc, c; | ||
| int w, cnt = 0; | ||
| string b[3] = {"Rock", "Paper", "Scissor"}; | ||
| int a[3] = { 1, 2, 3 }; | ||
| int uc, cc, c; | ||
|
|
||
| while(true) | ||
| { | ||
| cout<<"Enter 1 for Rock.\n"; | ||
| cout<<"Enter 2 for Paper.\n"; | ||
| cout<<"Enter 3 for Scissor.\n"; | ||
| cout<<"Enter your choice:\n"; | ||
| cin>>uc; | ||
|
|
||
| cc = a[(rand() % 3)]-1; | ||
| while (true) | ||
| { | ||
| cout << "Enter 1 for Rock.\n"; | ||
| cout << "Enter 2 for Paper.\n"; | ||
| cout << "Enter 3 for Scissor.\n"; | ||
| cout << "Enter your choice:\n"; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cout << "Enter your choice : " ; |
||
| cin >> uc; | ||
|
|
||
| cout<<"You chose: "<<b[uc-1]<<"\n"; | ||
| cout<<"Computer choose: "<<b[cc]<<"\n"; | ||
| cc = a[(rand() % 3)] - 1;// | ||
|
|
||
| if(a[uc-1] == 1) | ||
| { | ||
| if(a[cc] == 3) | ||
| { | ||
| w = 1; | ||
| } | ||
| else if(a[cc] == 2) | ||
| { | ||
| w = 0; | ||
| } | ||
| else | ||
| { | ||
| w = -1; | ||
| } | ||
| } | ||
| else if(a[uc-1] == 2) | ||
| { | ||
| if(a[cc] == 1) | ||
| { | ||
| w = 1; | ||
| } | ||
| else if(a[cc] == 3) | ||
| { | ||
| w = 0; | ||
| } | ||
| else | ||
| { | ||
| w = -1; | ||
| } | ||
| } | ||
| else | ||
| { | ||
| if(a[cc] == 2) | ||
| { | ||
| w = 1; | ||
| } | ||
| else if(a[cc] == 1) | ||
| { | ||
| w = 0; | ||
| } | ||
| else | ||
| { | ||
| w = -1; | ||
| } | ||
| } | ||
| cout << "You chose: " << b[uc - 1] << "\n"; | ||
| cout << "Computer choose: " << b[cc] << "\n"; | ||
|
|
||
| if(w == 1) | ||
| { | ||
| cout<<"You won!\n"; | ||
| } | ||
| else if(w == 0) | ||
| { | ||
| cout<<"You lose!\n"; | ||
| } | ||
| else | ||
| { | ||
| cout<<"Tie!\n"; | ||
| } | ||
| if (a[uc - 1] == 1) | ||
| { | ||
| if (a[cc] == 3) | ||
| { | ||
| w = 1; | ||
| } | ||
| else if (a[cc] == 2) | ||
| { | ||
| w = 0; | ||
| } | ||
| else | ||
| { | ||
| w = -1; | ||
| } | ||
| } | ||
| else if (a[uc - 1] == 2) | ||
| { | ||
| if (a[cc] == 1) | ||
| { | ||
| w = 1; | ||
| } | ||
| else if (a[cc] == 3) | ||
| { | ||
| w = 0; | ||
| } | ||
| else | ||
| { | ||
| w = -1; | ||
| } | ||
| } | ||
| else | ||
| { | ||
| if (a[cc] == 2) | ||
| { | ||
| w = 1; | ||
| } | ||
| else if (a[cc] == 1) | ||
| { | ||
| w = 0; | ||
| } | ||
| else | ||
| { | ||
| w = -1; | ||
| } | ||
| } | ||
|
|
||
| cout<<"Do you want to play again?\n"; | ||
| cout<<"Enter 1 for YES.\n"; | ||
| cout<<"Enter 2 for NO.\n"; | ||
| cin>>c; | ||
| if (w == 1) | ||
| { | ||
| cnt++; | ||
| cout << "You won!\n"; | ||
| } | ||
| else if (w == 0) | ||
| { | ||
| if(cnt>0) | ||
| cnt--; | ||
| cout << "You lose!\n"; | ||
| } | ||
| else | ||
| { | ||
| cout << "Tie!\n"; | ||
| } | ||
| cout << "Your score = " << cnt << endl; | ||
| cout << "Do you want to play again?\n"; | ||
| cout << "Enter 1 for YES.\n"; | ||
| cout << "Enter 2 for NO.\n"; | ||
| cin >> c; | ||
|
|
||
| if(c == 2) | ||
| { | ||
| cout<<"Session being terminated...\n"; | ||
| exit(0); | ||
| } | ||
| else if(c != 1) | ||
| { | ||
| cout<<"Wrong choice! Session being terminated...\n"; | ||
| exit(0); | ||
| } | ||
| else | ||
| { | ||
| cout<<"\e[1;1H\e[2J"; | ||
| cc=0; | ||
| uc=0; | ||
| } | ||
| if (c == 2) | ||
| { | ||
| cout << "Session being terminated...\n"; | ||
| cout << "Your Final Score = " << cnt; | ||
| exit(0); | ||
| } | ||
| else if (c != 1) | ||
| { | ||
| cout << "Wrong choice! Session being terminated...\n"; | ||
| exit(0); | ||
| } | ||
| else | ||
| { | ||
| cout << "\e[1;1H\e[2J"; | ||
| cc = 0; | ||
| uc = 0; | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
| return 0; | ||
| } | ||
| return 0; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#include