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 124 125 126 127 128 129 130 131 132 133 134 135 136
|
#include <iostream>
#include "Apothecary.h"
#ifdef _WIN32
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#endif
using namespace std;
char* PotionTypeString(PotionType type)
{
char* s = "";
switch (type) {
case SPEED:
s = "Speed";
break;
case STRENGTH:
s = "Strength";
break;
case HEALTH:
s = "Health";
break;
case WISDOM:
s = "Wisdom";
break;
}
return(s);
}
/*void BuyPotion(Apothecary& apo)
{
Potion potion;
if (apo.BuyPotion(potion)) {
cout << "Congratulations! You just bought a " << PotionTypeString(potion.GetType()) << " potion!" << endl;
cout << potion;
} else {
cout << "There were no potions available." << endl;
}
}*/
void OrderPotion(Apothecary& apo,PotionType type)
{
bool ret = apo.OrderPotion(type);
if (ret) {
cout << "Your potion (" << PotionTypeString(type) << ") has been added to the queue!" << endl;
} else {
cout << "The order queue is full." << endl;
}
}
void MakePotions(Apothecary& apo)
{
cout << "About to try to make some potions." << endl;
int count = apo.MakePotions();
cout << "Made " << count << " potions." << endl;
}
void TestApothecary()
{
Apothecary apo(5,20); // order limit, shelf limit
OrderPotion(apo,WISDOM);
OrderPotion(apo,WISDOM);
OrderPotion(apo,SPEED);
MakePotions(apo);
OrderPotion(apo,STRENGTH);
OrderPotion(apo,HEALTH);
OrderPotion(apo,HEALTH);
OrderPotion(apo,WISDOM);
OrderPotion(apo,STRENGTH);
OrderPotion(apo,HEALTH);
/*BuyPotion(apo);
BuyPotion(apo);
BuyPotion(apo);
BuyPotion(apo);
MakePotions(apo);
OrderPotion(apo,STRENGTH);
OrderPotion(apo,STRENGTH);
OrderPotion(apo,STRENGTH);
OrderPotion(apo,STRENGTH);
OrderPotion(apo,STRENGTH);
MakePotions(apo);
OrderPotion(apo,HEALTH);
OrderPotion(apo,WISDOM);
OrderPotion(apo,HEALTH);
OrderPotion(apo,WISDOM);
OrderPotion(apo,SPEED);
MakePotions(apo);
OrderPotion(apo,HEALTH);
OrderPotion(apo,HEALTH);
OrderPotion(apo,HEALTH);
OrderPotion(apo,HEALTH);
OrderPotion(apo,HEALTH);
MakePotions(apo);
OrderPotion(apo,HEALTH);
OrderPotion(apo,WISDOM);
OrderPotion(apo,HEALTH);
OrderPotion(apo,WISDOM);
OrderPotion(apo,SPEED);
MakePotions(apo);
BuyPotion(apo);
MakePotions(apo);*/
}
int main() {
TestApothecary();
#ifdef _WIN32
if (_CrtDumpMemoryLeaks()) {
cout << "Memory leaks!" << endl;
}
#endif
return 0;
}
|