From a376b4ee1918114253683701ad3cf6fffa152251 Mon Sep 17 00:00:00 2001 From: Nicholas Olson Date: Wed, 9 Sep 2015 13:39:49 -0700 Subject: [PATCH 01/10] Added framework for PigsGame --- Makefile | 1 + computer.c | 1 + computer.cpp | 1 + main.cpp | 1 + player.cpp | 1 + player.h | 1 + 6 files changed, 6 insertions(+) create mode 100644 Makefile create mode 100644 computer.c create mode 100644 computer.cpp create mode 100644 main.cpp create mode 100644 player.cpp create mode 100644 player.h diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..33ceb8f --- /dev/null +++ b/Makefile @@ -0,0 +1 @@ +Makefile \ No newline at end of file diff --git a/computer.c b/computer.c new file mode 100644 index 0000000..1848675 --- /dev/null +++ b/computer.c @@ -0,0 +1 @@ +//header file for computer \ No newline at end of file diff --git a/computer.cpp b/computer.cpp new file mode 100644 index 0000000..51b1ee5 --- /dev/null +++ b/computer.cpp @@ -0,0 +1 @@ +//cpp file for computer \ No newline at end of file diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..d7b0cdb --- /dev/null +++ b/main.cpp @@ -0,0 +1 @@ +//main.cpp \ No newline at end of file diff --git a/player.cpp b/player.cpp new file mode 100644 index 0000000..f8239d9 --- /dev/null +++ b/player.cpp @@ -0,0 +1 @@ +//cpp file for player \ No newline at end of file diff --git a/player.h b/player.h new file mode 100644 index 0000000..741773e --- /dev/null +++ b/player.h @@ -0,0 +1 @@ +//Header file for Player \ No newline at end of file From 5e662b41f913c625e0f716c2fdacd8c9cadab54e Mon Sep 17 00:00:00 2001 From: Nicholas Olson Date: Wed, 9 Sep 2015 13:48:43 -0700 Subject: [PATCH 02/10] makefile: added stuff so it exists on a branch --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 33ceb8f..9417dbb 100644 --- a/Makefile +++ b/Makefile @@ -1 +1,3 @@ -Makefile \ No newline at end of file +Makefile + +Dis is where we make stuffz \ No newline at end of file From 3551672ee6b5ccadf063a39401ce2b4a9d559f4a Mon Sep 17 00:00:00 2001 From: jakezehring Date: Sun, 13 Sep 2015 17:01:29 -0700 Subject: [PATCH 03/10] main.cpp update --- main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index d7b0cdb..5c7ef16 100644 --- a/main.cpp +++ b/main.cpp @@ -1 +1,7 @@ -//main.cpp \ No newline at end of file +//main file for pigsgame +#include +using namespace std; + +int main() +{ +} \ No newline at end of file From 745fdf9a16f1ce9528a8367be36715bc12b07956 Mon Sep 17 00:00:00 2001 From: jakezehring Date: Mon, 14 Sep 2015 11:16:56 -0700 Subject: [PATCH 04/10] Updated includes --- main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index 5c7ef16..a16bcf7 100644 --- a/main.cpp +++ b/main.cpp @@ -1,7 +1,9 @@ //main file for pigsgame #include +#include "player.h" using namespace std; int main() -{ +{ + } \ No newline at end of file From 8ad5e4af7af2caf53c0acd0dd3784fb4c9daad27 Mon Sep 17 00:00:00 2001 From: Enda Wang Date: Tue, 15 Sep 2015 02:22:33 +0800 Subject: [PATCH 05/10] update update this file --- computer.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/computer.cpp b/computer.cpp index 51b1ee5..1581666 100644 --- a/computer.cpp +++ b/computer.cpp @@ -1 +1,22 @@ -//cpp file for computer \ No newline at end of file +//cpp file for computer +#include +#include +using namespace std; + + +int computer(int playernum, int totalscore, int score) +{ + if(score == 1) + { + playernum++; + } + else + { + if(totalscore >= 100) + { + cout<<"Player "< Date: Mon, 14 Sep 2015 11:32:58 -0700 Subject: [PATCH 06/10] Built basic class and framework for class --- player.cpp | 24 +++++++++++++++++++++++- player.h | 20 +++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/player.cpp b/player.cpp index f8239d9..30fc27c 100644 --- a/player.cpp +++ b/player.cpp @@ -1 +1,23 @@ -//cpp file for player \ No newline at end of file +//cpp file for player + +#include"player.h" + +using namespace std; + +void Player:Player() +{ + +} + +void Player:ResetTurnScore() +{ + +} +void Player:CheckForContinue() +{ + +} +void Player:ReturnTotalScore() +{ + +} \ No newline at end of file diff --git a/player.h b/player.h index 741773e..567a46f 100644 --- a/player.h +++ b/player.h @@ -1 +1,19 @@ -//Header file for Player \ No newline at end of file +//Header file for Player +#ifndef PLAYER_H; +#define PLAYER_H; +using namespace std; + +Class Player +{ +Public: + Player() + void ResetTurnScore(); + void CheckForContinue(); + void ReturnTotalScore(); + +Private: + int TurnScore; + int TotalScore; +}; + +#endif \ No newline at end of file From 21e6a3cb39dc749abe9611c4f605776a51415afc Mon Sep 17 00:00:00 2001 From: Nicholas Olson Date: Mon, 14 Sep 2015 11:34:28 -0700 Subject: [PATCH 07/10] Added changes to makefile, flushed it out --- Makefile | 17 +++++++++++++++-- player.h | 3 ++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9417dbb..11ba851 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,16 @@ -Makefile +all: pigs -Dis is where we make stuffz \ No newline at end of file +pigs: main.o computer.o player.o + g++ main.o computer.o player.o -o pigs + +main.o: main.cpp + g++ -c main.cpp + +player.o: player.cpp player.h + g++ -c player.cpp player.h + +hello.o: computer.cpp computer.h + g++ -c computer.cpp computer.h + +clean: + rm *o pigs \ No newline at end of file diff --git a/player.h b/player.h index 741773e..139597f 100644 --- a/player.h +++ b/player.h @@ -1 +1,2 @@ -//Header file for Player \ No newline at end of file + + From 83e05fb0afb465583e1bbf0e83004ea47a79a59c Mon Sep 17 00:00:00 2001 From: Jacob Shouse Date: Mon, 14 Sep 2015 13:14:31 -0700 Subject: [PATCH 08/10] updated function returns, and finished CheckForContinue --- player.cpp | 27 ++++++++++++++++++++++----- player.h | 4 +++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/player.cpp b/player.cpp index 30fc27c..41c582d 100644 --- a/player.cpp +++ b/player.cpp @@ -4,20 +4,37 @@ using namespace std; -void Player:Player() +void Player:Player(int Score) { - + Score = TotalScore; } void Player:ResetTurnScore() { } -void Player:CheckForContinue() +bool Player:CheckForContinue() { - + string YesOrNo; + cout << "Roll Again? (y/n)" << endl; + while() + { + cin >> YesOrNo; + if ( cin == "y") + { + return true; + } + else if(cin == "n") + { + return false; + } + else + { + cout << "Please type a y or n" + } + } } void Player:ReturnTotalScore() { - + } \ No newline at end of file diff --git a/player.h b/player.h index 567a46f..092b84b 100644 --- a/player.h +++ b/player.h @@ -1,6 +1,8 @@ //Header file for Player #ifndef PLAYER_H; #define PLAYER_H; +#include +#include using namespace std; Class Player @@ -8,7 +10,7 @@ Class Player Public: Player() void ResetTurnScore(); - void CheckForContinue(); + bool CheckForContinue(); void ReturnTotalScore(); Private: From a25b1fef278dab7d5ba7fd7e04d597ac9e5ace44 Mon Sep 17 00:00:00 2001 From: jakezehring Date: Mon, 14 Sep 2015 13:24:38 -0700 Subject: [PATCH 09/10] Main loop with end conditions --- main.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/main.cpp b/main.cpp index a16bcf7..88c4fba 100644 --- a/main.cpp +++ b/main.cpp @@ -1,9 +1,28 @@ //main file for pigsgame #include +#include #include "player.h" using namespace std; int main() { - + player p; + computer c; + int player_win = 0; + int computer_win = 0; + while(1) + { + player_win = p.turn(); + if(player_win >= 100) + { + cout << "Player Wins!\n"; + exit(0); + } + computer_win = c.turn(); + if(computer_win >= 100) + { + cout << "Computer Wins!\n"; + exit(0); + } + } } \ No newline at end of file From 4b7846ee53a676e883441fb1538230b9f5c629b8 Mon Sep 17 00:00:00 2001 From: Jacob Shouse Date: Mon, 14 Sep 2015 22:00:07 -0700 Subject: [PATCH 10/10] Created PlayerTurn function --- player.cpp | 22 ++++++++++++++++++++++ player.h | 1 + 2 files changed, 23 insertions(+) diff --git a/player.cpp b/player.cpp index 41c582d..b3bc2f4 100644 --- a/player.cpp +++ b/player.cpp @@ -37,4 +37,26 @@ bool Player:CheckForContinue() void Player:ReturnTotalScore() { +} + +void Player:PlayerTurn() +{ + int dice; + while() + { + dice = rand () % 6 + 1; + if (dice == 1) + { + ResetTurnScore(); + return; + } + TurnScore = TurnScore + dice; + if(CheckForContinue()) + { + } + else + { + return; + } + } } \ No newline at end of file diff --git a/player.h b/player.h index 092b84b..8f7d1e8 100644 --- a/player.h +++ b/player.h @@ -12,6 +12,7 @@ Class Player void ResetTurnScore(); bool CheckForContinue(); void ReturnTotalScore(); + void PlayerTurn(); Private: int TurnScore;