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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
map<string,double> books;
map<string,double> games;
void load_book (const string & bookname, double price)
{ books.insert (pair<string,double> (bookname, price));
}
void load_game (const string & gamename, double price)
{ games.insert (pair<string,double> (gamename, price));
}
void load_book_inventory ()
{ load_book ("D&D Fortune Cards: Fury Of The Feywild", 39.99);
load_book ("D&D Fortune Cards: Neverwinter", 39.99);
load_book ("D&D Fortune Cards: Shadow Over Nentir Vale", 39.99);
load_book ("D&D Fortune Cards: Spiral Of Tharizdun", 39.99);
load_book ("3.5 Edition Premium Spell Compendium", 29.99);
load_book ("A Practical Guide To Monsters", 29.99);
load_book ("AD&D 2nd Ed Dungeon Masters Guide", 29.99);
load_book ("Demonomicon", 29.99);
load_book ("Divine Power", 29.99);
load_book ("Draconomicon Metallic Dragons", 29.99);
load_book ("Dragon Magazine Annual", 29.99);
load_book ("E3 Prince Of Undead", 29.99);
load_book ("Elminsters Forgotten Realms", 29.99);
load_book ("Executioner Token Set", 29.99);
load_book ("Martial Power 2", 29.99);
load_book ("Players Strategy Guide", 29.99);
load_book ("Power Cards: Warlord Power Cards", 29.99);
load_book ("Psionic Powers", 29.99);
load_book ("Revenge Of The Giants", 29.99);
load_book ("The Plane Above Secrets Of The Astral Sea", 29.99);
load_book ("The Plane Below Secrets Of The Elemental Chaos", 29.99);
load_book ("Underdark", 29.99);
}
double buy_book ()
{ string bookname;
double bookprice;
int copies;
map<string,double>::const_iterator citer;
cout << "Enter book name to search for: ";
getline (cin, bookname);
citer = books.find (bookname);
if (citer == books.end())
{ cout << "Book name not found" << endl;
return 0;
}
bookprice = citer->second;
cout << "That book is CDN$ " << bookprice << endl;
do
{ cout << "How many copies would you like? You can buy up to five copies max." << endl;
cin >> copies;
if (copies >= 1 && copies <= 5)
{ cout << copies <<" copies of it havae been added to your cart.\n";
}
else
{ cout << "Copies not valid. Please try again.\n";
}
} while (copies < 1 || copies > 5);
bookprice = citer->second * copies;
return bookprice;
}
void load_game_inventory ()
{ load_game ("A Game Of Thrones LCG 2ND ED. Calm Over Westeros", 31.42);
load_game ("A Game Of Thrones LCD 2ND ED. Ironborn Reavers Playmat", 31.42);
load_game ("A Game Of Thrones LCD 2ND ED. Kingslayer Playmat", 31.42);
load_game ("40k Forbidden Stars", 130.63);
load_game ("504", 130.62);
load_game ("A Game of Thrones Board Game", 130.63);
load_game ("A Game Of Thrones LCG 2ND ED. Calm Over Westeros", 130.63); // Duplicate ???
load_game ("Aliens Vs Predators", 130.63);
load_game ("Empires Age Of Discovery W/EXP EGL", 130.63);
load_game ("Star Wars Imperial Assault", 130.63);
load_game ("Star Wars Armada", 130.63);
load_game ("Star Wars XMG Imperial Raider", 130.63);
load_game ("Ticket To Ride 10th Anniversary Edition", 130.63);
load_game ("Super Dungeon Explore Forgotten King", 130.63);
load_game ("Zombicide Expansion: Prison Outbreak", 130.63);
load_game ("Mega Man The Board Game", 130.63);
load_game ("Twilight Imperium 3RD Edition", 130.63);
load_game ("Rum and Bones Core Set", 130.63);
load_game ("Eclipse", 130.63);
load_game ("Zombicide Season 3: Rue Morgue", 130.63);
load_game ("Myth", 130.63);
load_game ("Iron Kingdoms Undercity", 130.63);
load_game ("Caverna: The Cave Farmers", 130.63);
load_game ("Space Cadets Away Missions", 130.63);
}
double buy_game ()
{ string boardgame;
map<string,double>::const_iterator citer;
double gameprice;
int copies;
cout<<"Please enter the name of the board game.\n";
getline (cin, boardgame);
citer = games.find (boardgame);
if (citer == games.end())
{ // Not found
cout << "Board game not found" << endl;
return 0;
}
gameprice = citer->second;
cout << "That game is CDN$ " << gameprice << endl;
while (true)
{ cout << "How many copies would you like? You can buy up to two copies max." << endl;
cin >> copies;
if (copies == 1 || copies == 2)
{ cout << copies << " copies of it have been added to your cart." << endl;;
return gameprice * copies;
}
cout << "Copies not valid. Please try again.\n";
}
}
int main ()
{ char search;
int searchitem;
char checkout;
double subtotal = 0;
load_book_inventory ();
load_game_inventory ();
cout<<"You get an option to browse all categories or search our inventory.\n";
do
{ cout<<"Do you want to search our inventory, y/n\n";
cin>>search;
if (search == 'y')
{ cout<<"Let's start with a general description of what you would like to see.\n";
cout<<"Enter the number of the description.\n";
cout<<"1. Books\n";
cout<<"2. Board Games\n";
cout<<"3. Wizard Tower Clothing\n";
cout<<"4. Funko\n";
cin>>searchitem;
if (searchitem == 1)
subtotal += buy_book ();
if(searchitem == 2)
subtotal += buy_game ();
}
} while (search = 'y');
cout<<"Do you want to check out? y/n\n";
cin>>checkout;
}
|