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
|
#include <cstdlib>
#include <iostream>
#include <ctime>
using namespace std;
void game (int diceValue, int body, int head, int ant, int eyes, int tongue, int legs);
int rollDice();
bool checkForWin(int body, int head, int ant, int eyes, int tongue, int legs);
int main(int argc, char *argv[])
{
srand(time(0));
int body = 0, int head = 0, int ant = 0, int eyes = 0, int tongue = 0, int legs = 0;
int diceValue;
while (!checkForWin(int &body, int &head, int &ant, int &eyes, int &tongue, int &legs))
{
diceValue = rollDice();
int game(int diceValue, int &body, int &head, int &ant, int &eyes, int &tongue, int &legs);
}
system("PAUSE");
return EXIT_SUCCESS;
}
int rollDice() {
cout << "Rolling Dice" << endl;
int dice = rand() % 6 + 1;
cout << "You rolled a: " << dice << endl;
return dice;
}
void game (int &body=0, int &head=0, int &ant=0, int &eyes=0, int &tongue=0, int &legs=0, int diceValue) {
// Getting a body
if (diceValue == 1 && body < 1 ) {
cout << "You got a body!! " << endl;
body++;
}
else {
cout << "You already have a body..." << endl;
}
// Getting a head
if (diceValue == 2 && body == 1) {
cout << "You got a head!!! " << endl;
head++;
}
else {
cout << "You must get a body first! " << endl;
}
// Getting antannae
if (diceValue == 3 && head == 1) {
cout << "You got an Antannae" << endl;
}
else {
cout << "You can't get an Antannae. You have no place to put it!";
}
}
bool checkForWin(int &body, int &head, int &ant, int &eyes, int &tongue, int &legs) {
// return true if you win
// return false otherwise
if (int &body=1 && int &head=1 && int &ant=1 && int &eyes=1 && int &tongue=1 && int &legs=6){
return true;
}
else {
return false;
}
}
|