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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
|
#include <iostream>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <cstdlib>
using namespace std;
//Global variable
const string cardfile=("cards.txt");
//Function Prototypes
void readCards();
int RandomCardP1 (int);
int RandomCardP2 (int);
int CheckType (int [], int ,int);
int CheckSystem (int [], int ,int );
void ShowCardP1(int , string [], string [], string [], string[] , string []);
void ShowCardP2(int, string [], string [], string [], string [], string []);
int Score(int ,int ,int [],int []);
int FinalScore (int,int);
int main(){
//score
int sctype[SIZE]={ 3,2,1,2,3,4,1,2,2,2 };
int scsystem[SIZE]={ 6,4,2,1,5,7,1,2,3,5 };
//loop for game
do{
int scP1=0,scP2=0;
for (int round=1;round<6;round++)
{//loop for 5 round
cout <<"\t***********";
cout<<endl<<"\t ROUND "<<round<<"\n";
cout <<"\t***********";
cout<<endl;
//announce winner and score for each round
Score(IDcardP1,IDcardP2,sctype-1,scsystem-1);
cout<<endl;
cin.get();
cout<<endl<<endl;
}//end loop for round
//score total round
FinalScore(scP1,scP2);
} while(respond=='Y'||respond=='y');//end loop for game
}//end main
//scores for each round
int Score(int IDcardP1,int IDcardP2,int sctype[],int scsystem[]){
int scP1, scP2;
cout << "The winner for this round is " <<endl<<endl;
if (sctype[IDcardP1]>sctype[IDcardP2])
{
cout << " PLAYER 1 " <<endl;
scP1+=10;
cout<<endl;
}
else
{
if (scsystem[IDcardP1]>scsystem[IDcardP2])
{
cout << " PLAYER 1 " <<endl;
scP1+=10;
cout<<endl;
}
else
{
cout << " PLAYER 2 " <<endl;
scP2+=10;
}
cout<<endl;
}
//display score for each round
cout << "The scores for this round"<<endl;
cout<<"####################################"<<endl;
cout<<" Player 1 score :"<<scP1<<endl;
cout<<" Player 2 score :"<<scP2<<endl;
cout<<"####################################"<<endl;
}
//score for all round
int FinalScore(int scP1,int scP2){
//score total round
cout << "+++++++++++++++++++++++++++++++++"<<endl;
cout << " Your scores for 5 round : "<< endl;
cout << " Player 1's score: " << scP1<<endl;
cout << " Player 2's score: " << scP2<<endl;
cout << "+++++++++++++++++++++++++++++++++"<<endl;
cout <<endl;
//announce the winner for this game
if (scP1>scP2)
cout << "\tPLAYER 1 WON!" << endl << endl;
else
cout << "\tPLAYER 2 WON!" << endl << endl;
cout<<endl;
}
|