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

Resolved Split or Steal issues #12

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
language: cpp
os: linux
script:
- make
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.org/kippyan/SplitorSteal.svg?branch=master)](https://travis-ci.org/kippyan/SplitorSteal)

# SplitOrSteal

**Split Or Steal** is a console application 2-player game. Each player provides their first name and then individually decides if they want to "split" or "steal." If both players choose "split" then they both get half of the prize. However, if one chooses "split" while the other chooses "steal," the player who stole gets the entire prize (and the other gets nothing). Unfortunately, if both players are greedy and both choose "steal" then they both lose!
Expand All @@ -12,3 +14,4 @@ Notes:

* Each player should only enter their first names
* The first player's choice is only "hidden" by using a lot of blank lines... technically, the second player can cheat by scrolling up

78 changes: 32 additions & 46 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -1,73 +1,59 @@
//Kevin Buffardi (with help of class)
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main()
{
//player names
string player1name = "";
string player2name = "";

//player responses
char decision1 = ' ';
char decision2 = ' ';


char keepPlaying = 'Y';
cout<<"Player 1, please enter your name: ";
cin>>player1name;
cout<<"Player 2, please enter your name: ";
cin>>player2name;

cout<<"WELCOME TO SPLIT OR STEAL!\n";

cout<<player1name<<", please enter the character of your choice...\n";
cout<<"Please enter (s)plit or s(t)eal: ";
cin>>decision1;

cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
while(tolower(keepPlaying) == 'y'){
cout<<"WELCOME TO SPLIT OR STEAL!\n";
cout<<player1name<<", please enter the character of your choice...\n";
cout<<"Please enter (s)plit or s(t)eal: ";
cin>>decision1;
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";

cout<<player2name<<", please enter the character of your choice...\n";
cin>>decision2;

if(decision1 == 't' && decision2 == 's')
{
cout<<player1name<<" stole while "<<player2name<<" split. "
cout<<player2name<<", please enter the character of your choice...\n";
cin>>decision2;
if(tolower(decision1) == 't' && tolower(decision2) == 's')
{
cout<<player1name<<" stole while "<<player2name<<" split. "
<<player1name<<" WINS ALL OF THE PRIZE!\n";
}
else if(decision2 == 't' && decision1 == 's')
{
cout<<player2name<<" stole while "<<player1name<<" split. "
}
else if(tolower(decision2) == 't' && tolower(decision1) == 's')
{
cout<<player2name<<" stole while "<<player1name<<" split. "
<<player2name<<" WINS ALL OF THE PRIZE!\n";
}
else if(decision1 == 's' && decision2 == 's')
{
cout<<"Both players cooperated and chose to split. Congrats, "
}
else if(tolower(decision1) == 's' && tolower(decision2) == 's')
{
cout<<"Both players cooperated and chose to split. Congrats, "
<<player1name<<" and "<<player2name<<" you each get half the prize!\n";
}
else
{
cout<<"Sorry, you were both greedy and chose to steal. Neither of you "
}
else
{
cout<<"Sorry, you were both greedy and chose to steal. Neither of you "
<<"win a prize and go home with NOTHING!\n";
}
cout<< "Enter Y to play again or N to quit.\n";
cin >> keepPlaying;
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
}
















return 0;
}