hw7_main.cpp

/* Programmer: Jennifer Leopold

Date: March 8, 2018

File: hw7_main.cpp

Purpose: Program that simulates a main character (BoJack

Horseman) randomly encountering various other

characters and collecting cards of different sizes.

The simulation ends when he has collected a certain

number of characters or has collected a certain

number of cards that can be stacked on top of each

other.

To compile: fg++ hw7_main.cpp hw7_functs.cpp -o hw7

To execute: ./hw7

*/

#include <iostream>

#include <ctime>

#include <cstdlib>

#include "hw7_functs.h"

using namespace std;

int main()

{

// Seed the random number generator

srand(time(NULL));

int numCreaturesSeenSoFar = 0;

int numCards = 0;

Creature cards[MAX_NUM_CARDS_TO_COLLECT];

int whichCreature;

bool quit;

bool creaturesSeenSoFar[NUM_CREATURES];

// Output welcome message

greeting();

// Keep track of # different creatures seen; initialize

// entry to false for each creature in an array

initCreaturesSeenSoFar(creaturesSeenSoFar, NUM_CREATURES);

do

{

// Randomly pick a creature for BoJack to encounter

whichCreature = myRand(0, NUM_CREATURES-1);

recordDifferentCreaturesSeen(whichCreature,

creaturesSeenSoFar,

NUM_CREATURES,

numCreaturesSeenSoFar);

randomlyOutputCreatureGreeting(whichCreature);

// Quit when certain # of creatures seen or

// certain # of cards are found to be stackable

if (numCreaturesSeenSoFar == MIN_DIFFERENT_CREATURES_TO_SEE)

{

quit = true;

cout << "\nOK, you've seen enough different creatures. ";

}

else

{

addCreatureCardToCollection(whichCreature, cards,

numCards);

sortArray(cards, numCards);

quit = numCardsStackable(cards, numCards) >=

MIN_CARDS_TO_STACK;

if (quit)

printStackableCards(cards, numCards, MIN_CARDS_TO_STACK);

}

} while (!quit);

// Sign-off

signOff();

return 0;

}