diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..11ba851 --- /dev/null +++ b/Makefile @@ -0,0 +1,16 @@ +all: pigs + +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/computer.cpp b/computer.cpp new file mode 100644 index 0000000..1581666 --- /dev/null +++ b/computer.cpp @@ -0,0 +1,22 @@ +//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 "< +#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 diff --git a/player.cpp b/player.cpp new file mode 100644 index 0000000..b40f763 --- /dev/null +++ b/player.cpp @@ -0,0 +1,62 @@ +//cpp file for player + +#include"player.h" + +using namespace std; + +void Player:Player(int Score) +{ + Score = TotalScore; +} + +void Player:ResetTurnScore() +{ + TurnScore=0; +} +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" + } + } +} +int Player:ReturnTotalScore() +{ + return TurnScore+TotalScore; +} + +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 new file mode 100644 index 0000000..4bdc750 --- /dev/null +++ b/player.h @@ -0,0 +1,21 @@ +#ifndef PLAYER_H; +#define PLAYER_H; +#include +#include +using namespace std; + +Class Player +{ +Public: + Player() + void ResetTurnScore(); + bool CheckForContinue(); + void ReturnTotalScore(); + void PlayerTurn(); + +Private: + int TurnScore; + int TotalScore; +}; + +#endif