Here's the code:
//A game where you manage a bar, buying and selling drinks, NOW you can save your game!
//Created by Gilad "Speaker For The Dead" Barlev
//Final Programming Edit on 16/1/02 (D/M/Y)
//Final Internal Documentation Edit on 15/1/02 (D/M/Y)
#include <iostream.h>
#include <conio.h>
#include <fstream.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
//using namespace std;
//function prototypes
int calcPrice (int);
float buyDrink(int, float);
float setPrice(int, int, string);
int sellDrink(string, int, int, float);
void clrScr();
int main ()
{//main function
//declare variables
int x = 0;
char y = ' ';
float dollars = float(100);
int beerQty = 10;
int wineQty = 10;
int martiniQty = 10;
int vodkaQty = 10;
int whiskeyQty = 10;
int beerWhole = 0;
int wineWhole = 0;
int martiniWhole = 0;
int vodkaWhole = 0;
int whiskeyWhole = 0;
int beerPaco = 0;
int winePaco = 0;
int martiniPaco = 0;
int vodkaPaco = 0;
int whiskeyPaco = 0;
float beerPrice = 0.0;
float winePrice = 0.0;
float martiniPrice = 0.0;
float vodkaPrice = 0.0;
float whiskeyPrice = 0.0;
int beerSold = 0;
int wineSold = 0;
int martiniSold = 0;
int vodkaSold = 0;
int whiskeySold = 0;
float earnings = 0.0;
int event = 0;
int day = 0;
//initialze random number generator
srand (time (NULL));
//intro
cout << "Speaker For The Dead Presents..." << endl << endl;
getch ();
//Game Intro
cout << " @@@@@@ " << endl
<< " @ 0 0 @ " << endl
<< " @ @ " << endl
<< " @ V @ " << endl
<< " @@@@@@ " << endl
<< " @@ " << endl
<< " @@@@ " << endl
<< " @ @@ @ " << endl
<< " ------------------------" << endl
<< " [ ## # * %%%% ]" << endl
<< " [ # # # * % ]" << endl
<< " [ #### # %%%% ]" << endl
<< " [ # # # % ]" << endl
<< " [ # # ##### %%%% ]" << endl
<< " [ ]" << endl
<< " [ TREETOP TAVERN ]" << endl;
getch ();
cout << endl << "'Hello, I'm AL!'" << endl;
getch();
cout << endl << "'How would you like to take" << endl << "over my tavern for a week?'" << endl;
getch();
clrScr();
Main:
//main menu
cout << "AL'S TREETOP TAVERN v1.0" << endl << "(1) Instructions" << endl << "(2) Main Game" << endl << "(3) Quit" << endl;
cin >> x;
if (x != 1 && x != 2)
{//quit
goto Credits;
}//end quit
if (x == 1)
{//instructions
cout << endl << endl << endl << "Here are AL's instructions:" << endl << endl;
getch ();
cout << " ______________________________________________________" << endl
<< "[You'll be managing my tavern for a week, ]" << endl
<< "[buying and selling booze. ]" << endl
<< "[while competing with Paco's tavern down the road. ]" << endl
<< "[Your goal is to rake up as much dough as you can. ]" << endl
<< "[Remember: ]" << endl
<< "[ People will not buy booze from you if they can ]" << endl
<< "[get it somewhere else for a lesser price. ]" << endl
<< "[ ]" << endl
<< "[Bye! ]" << endl
<< "[______________________________________________________]" << endl;
goto Main;
}//end instructions
if (x == 2)
{//game
//declare fstream commands
ifstream fin;
ofstream fout;
//load game
string file;
cout << "Enter name of new or previous game:" << endl;
cin >> file;
fin.open(file.c_str());
if (!fin.is_open() )
{//create new game
cout << "File not fount. Creating new file..." << endl;
}//end create new game
else
{//load game
fin >> day;
fin >> dollars;
fin >> beerQty;
fin >> wineQty;
fin >> martiniQty;
fin >> vodkaQty;
fin >> whiskeyQty;
}//end load game
while (day < 7)
{//day loop
day = day + 1;
//calculate prices
beerWhole = calcPrice(1);
wineWhole = calcPrice(2);
martiniWhole = calcPrice(4);
vodkaWhole = calcPrice(5);
whiskeyWhole = calcPrice(6);
beerPaco = calcPrice(2);
winePaco = calcPrice(3);
martiniPaco = calcPrice(5);
vodkaPaco = calcPrice(6);
whiskeyPaco = calcPrice(7);
getch();
//event creator
event = 1 + rand () % (3);
if (event == 1)
{//event selector
clrScr();
event = 1 + rand () % (7);
if (event == 1 || event == 2)
{//paco goes mad
cout << endl << "Paco goes mad!" << endl << "He raises prices to the point of insanity!" << endl;
beerPaco = 9;
winePaco = 9;
martiniPaco = 9;
vodkaPaco = 9;
whiskeyPaco = 9;
}//end paco's madness
if (event == 3 || event == 4)
{//vodka confiscated
cout << endl << "Health Inspectors confiscate your Vodka" << endl;
vodkaQty = 0;
}//end of confiscation
if (event == 5 || event == 6)
{//new brewry
cout << endl << "New Local Brewry!" << endl << "Wholesale Prices Plummet!!!" << endl;
beerWhole = 1;
wineWhole = 1;
martiniWhole = 3;
vodkaWhole = 4;
whiskeyWhole = 5;
}//end brewry
if (event == 7)
{//robbery
cout << endl << "A man in a donkey-suit holds up your store" << endl << "and steals ALL YOUR MONEY!" << endl;
dollars = 0;
}//end robbery
getch();
}//end event selector
Game:
//main game menu
clrScr();
cout << endl << endl << "AL'S TREETOP TAVERN - DAY " << day << endl << "(1)Buy Drinks" << endl << "(2)Compare Prices" << endl << "(3)Check Stocks" << endl << "(4)OPEN SHOP" << endl << "(5)Quit" << endl << endl << "Enter selection=? ";
cin >> x;
if (x != 1 && x != 2 && x != 3 && x != 4)
{//quit
goto Credits;
}//end quit
if (x == 1)
{//buy drinks
cout << endl << "BUY DRINKS - DAY " << day << endl << "(1)Beer $" << beerWhole << endl << "(2)Wine $" << wineWhole << endl << "(3)Martini $" << martiniWhole << endl << "(4)Vodka $" << vodkaWhole << endl << "(5)Whiskey $" << whiskeyWhole << endl << "Enter selection=?";
cin >> x;
if (x == 1)
{//buy beer
cout << endl << "BEER:" << endl;
x = buyDrink(beerWhole, dollars);
dollars = dollars - (beerWhole * x);
beerQty = beerQty + x;
goto Game;
}//end buy beer
if (x ==2)
{//buy wine
cout << endl << "WINE:" << endl;
x = buyDrink(wineWhole, dollars);
dollars = dollars - (wineWhole * x);
wineQty = wineQty + x;
goto Game;
}//end buy wine
if (x == 3)
{//buy martini
cout << endl << "MARTINI:" << endl;
x = buyDrink(martiniWhole, dollars);
dollars = dollars - (martiniWhole * x);
martiniQty = martiniQty + x;
goto Game;
}//end buy martini
if (x == 4)
{//buy vodka
cout << endl << "VODKA:" << endl;
x = buyDrink(vodkaWhole, dollars);
dollars = dollars - (vodkaWhole * x);
vodkaQty = vodkaQty + x;
goto Game;
}//end buy vodka
if (x == 5)
{//buy whiskey
cout << endl << "WHISKEY:" << endl;
x = buyDrink(whiskeyWhole, dollars);
dollars = dollars - (whiskeyWhole * x);
whiskeyQty = whiskeyQty + x;
goto Game;
}//end buy whiskey
goto Game;
}//end buy drinks
if (x == 2)
{//paco's prices
cout << endl << endl << "PACO'S PRICES - DAY " << day << endl << "Beer $" << beerPaco << endl << "Wine $" << winePaco << endl << "Martini $" << martiniPaco << endl << "Vodka $" << vodkaPaco << endl << "Whiskey $" << whiskeyPaco << endl << endl << "Press any key to continue" << endl;
getch();
goto Game;
}//end paco's prices
if (x == 3)
{//check stocks
cout << endl << endl << "STOCKS - DAY " << day << endl << "Beer: " << beerQty << endl << "Wine: " << wineQty << endl << "Martini: " << martiniQty << endl << "Vodka: " << vodkaQty << endl << "Whiskey: " << whiskeyQty << endl << endl << "Press any key to continue" << endl;
getch();
goto Game;
}//end check stocks
if (x == 4)
{//open shop
cout << "Are you sure (Y/N)? ";
cin >> y;
if (y != 'y' && y != 'Y')
{//cancel open shop
goto Game;
}//end cancel
//set selling prices
clrScr();
cout << endl << endl << endl << "SET SELLING PRICES - DAY " << day << endl;
beerPrice = setPrice(beerWhole, beerPaco, "BEER"

;
winePrice = setPrice(wineWhole, winePaco, "WINE"

;
martiniPrice = setPrice(martiniWhole, martiniPaco, "MARTINI"

;
vodkaPrice = setPrice(vodkaWhole, vodkaPaco, "VODKA"

;
whiskeyPrice = setPrice(whiskeyWhole, whiskeyPaco, "WHISKEY"

;
}//end open shop
clrScr();
//day's results
cout << "DAY " << day << endl;
getch();
earnings = 0;
beerSold = sellDrink("Beer", beerQty, beerPaco, beerPrice);
beerQty = beerQty - beerSold;
earnings = beerSold * beerPrice + earnings;
wineSold = sellDrink("Wine", wineQty, winePaco, winePrice);
wineQty = wineQty - wineSold;
earnings = wineSold * winePrice + earnings;
martiniSold = sellDrink("Martini", martiniQty, martiniPaco, martiniPrice);
martiniQty = martiniQty - martiniSold;
earnings = martiniSold * martiniPrice + earnings;
vodkaSold = sellDrink("Vodka", vodkaQty, vodkaPaco, vodkaPrice);
vodkaQty = vodkaQty - vodkaSold;
earnings = vodkaSold * vodkaPrice + earnings;
whiskeySold = sellDrink("Whiskey", whiskeyQty, whiskeyPaco, whiskeyPrice);
whiskeyQty = whiskeyQty - whiskeySold;
earnings = whiskeySold * whiskeyPrice + earnings;
getch();
cout << "Total Earnings: $" << earnings << endl;
dollars = dollars + earnings;
//save game
fout.open(file.c_str());
fout << day << endl;
fout << dollars << endl;
fout << beerQty << endl;
fout << wineQty << endl;
fout << martiniQty << endl;
fout << vodkaQty << endl;
fout << whiskeyQty << endl;
fout.close();
cout << "GAME SAVED." << endl;
}//end day loop
fin.close();
}//end game
//conclusion
clrScr();
cout << " @@@@@@ " << endl
<< " @ 0 0 @ " << endl
<< " @ @ " << endl
<< " @ V @ " << endl
<< " @@@@@@ " << endl
<< " @@ " << endl
<< " @@@@ " << endl
<< " @ @@ @ " << endl
<< " ------------------------" << endl
<< " [ ## # * %%%% ]" << endl
<< " [ # # # * % ]" << endl
<< " [ #### # %%%% ]" << endl
<< " [ # # # % ]" << endl
<< " [ # # ##### %%%% ]" << endl
<< " [ ]" << endl
<< " [ TREETOP TAVERN ]" << endl;
getch ();
cout << endl << "'Hey! I'm back!'" << endl;
getch ();
cout << endl << "'How much money didja make?'" << endl << endl << "$" << dollars << endl;
getch ();
if (dollars < 100)
{//pathetic
cout << endl << "'You made me LOSE money! Get out, punk!'" << endl;
}//end pathetic
if (dollars >= 100 && dollars < 200)
{//bad
cout << endl << "'You barely made me ANY money! Get out, punk!'" << endl;
}//end bad
if (dollars >= 200 && dollars < 500)
{//not bad
cout << endl << "'Not bad for a beginner.'" << endl;
}//end not bad
if (dollars >=500 && dollars < 1000)
{//thanks
cout << endl << "'Thanks! Wanna free beer? Too bad!'" << endl;
}//end thanks
if (dollars > 1000)
{//whoah
cout << endl << "'Whoah! How'd you like to WORK here?'" << endl << "'How 'bout when you turn 21?'" << endl;
}//end whoah
getch();
Credits:
//credits
clrScr();
cout << "This program was made by Speaker For The Dead for entertainment purposes only." << endl << "For problems with this program or more information on Speaker For The Dead," << endl<< "Please send an email to the_sftd@yahoo.com" << endl;
return 0;
}//end of main function
/*****PROGRAM DEFINED FUNCTIONS*****/
int calcPrice(int min)
{//random price creator
return min + rand() % (3);
}//end of price creator
float buyDrink(int price, float dollars)
{//drink buyer
int y = -1;
cout << "$" << price << " a jug" << endl << "You have $" << dollars << endl;
while (y < 0 || y * price > dollars)
{//purchase ammount
cout << "How much ya gonaa buy? ";
cin >> y;
}//end purchase ammount
return y;
}//end of drink buyer
float setPrice(int whole, int paco, string drink)
{//selling-price setter
float price = 0.0;
cout << endl << endl << drink << endl << "Wholesale Price $" << whole << endl << "Paco's Price $" << paco << endl << "Your price $";
cin >> price;
return price;
}//selling-price setter
void clrScr()
{//clear screen function
int x = 0;
while (x < 25)
{//clrscreen
cout << endl;
x = x + 1;
}//end clrscreen
}//end clear screen
int sellDrink(string drink, int qty, int paco, float price)
{//drink seller
int x = 0;
int sold = 0;
int y = 0;
int z = 0;
cout << drink << " sold: ";
if (paco > price)
{
y = 10;
}
if (paco == price)
{
y = 5;
}
if (paco < price)
{
y = 0;
}
while (x < y && qty > 0)
{//selling loop
z = 0 + rand() % (2);
qty = qty - z;
sold = sold + z;
x = x + 1;
}//end selling loop
cout << sold << endl << drink << " remaining: " << qty << endl;
return sold;
}//end drink seller
//This program was made by Speaker For The Dead for entertainment purposes only.
//For problems with this program or more information on Speaker For The Dead,
//Please send an email to the_sftd@yahoo.com