Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<Windows.h>
- #include<ctime>
- #include<string>
- using namespace std;
- /*
- To-Do List:
- - Create a method so you can purchase things from the shop. *DONE*
- - Every day, randomly choose a weather condition *DONE*
- - Every day, let the player choose which type of lemonade to make and deplete the supplies and add the lemonade. *DONE*
- - Every day, let a random number of customers come to the stand and decide on buying lemonade based on the percentages in the buyChance array.*DONE*
- - Make a goal for making say 300 dollars by the end of the game or you lose. *DONE*
- - Make ASCII Art for winning / losing
- - Finish Losing Conditions (Not needed?)
- */
- int SLEEP_TIME = 350, GOAL = 100, DAYS_ALLOWED = 10, cups = 0, uses = 0, sugar = 0, fullCups = 0, lemons = 0, ice = 0, days = 1, customerType = 0, consecutive = 0, type, weatherIndex;
- double money = 30.00, chargingPrice;
- double prices[] = {2.00, 4.00, 5.00, 1.50};
- string weather[] = {"Cloudy", "Rainy", "Windy", "Dry", "Fair", "Sunny"};
- string types[] = {"Sweet", "Normal", "Sour"};
- int buyChance[3][6] = {{23, 15, 17, 35, 30, 32},{25, 19, 20, 30, 35, 27},{24, 15, 23, 37, 32, 34}}; // {Sweet, Normal, Sour} Percent Chances of Purchase
- //Convenient random method
- int ran(int min, int max) {
- return min + rand() % (max - min + 1);
- }
- void displayShop() {
- Sleep(SLEEP_TIME);
- string stock[] = {"5 Sugar Packets (Satisfies one pitcher of normal lemonade)", "Lemon (Satisfies one pitcher of normal lemonade)", "Ice bag (Fills 1 Pitcher)", "Stack of 30 cups (Satisfies one pitcher)", "Exit"};
- cout << "General Store -- Your Money: $" << money << endl;
- cout << "Your stock -- Sugar(" << sugar << "), Lemons(" << lemons << "), Ice Bags(" << ice << "), Cups(" << cups << ")" << ", Full Cups(" << fullCups << ")" << endl;
- for(int index = 0; index < 5; index++) {
- if(index == 4)
- cout << "(5) Exit." << endl;
- else
- cout << "(" << index + 1 << ") " << stock[index] << " - $" << prices[index] << endl;
- }
- }
- void displayLemonade() {
- Sleep(SLEEP_TIME);
- cout << "Your stock: Sugar(" << sugar << "), Lemons(" << lemons << "), Ice Bags(" << ice << "), Cups(" << cups << ")" << ", Full Cups(" << fullCups << ")" << endl;
- cout << "(1) Sweet Lemonade (10 sugar packets, 1 lemon, 1 bag of ice, 30 cups)" << endl;
- cout << "(2) Normal Lemonade (5 sugar packets, 1 lemon, 1 bag of ice, 30 cups)" << endl;
- cout << "(3) Sour Lemonade (5 sugar packets, 2 lemons, 1 bag of ice, 30 cups)" << endl;
- cout << "(4) Exit." << endl;
- }
- void make(int id) {
- if(fullCups > 0 && id != type) {
- cout << "You cannot make more lemonade of a different type while you already have some!" << endl;
- return;
- }
- switch(id) {
- case 1:
- if(sugar >= 10 && lemons >= 1 && ice >= 1 && cups >= 30) {
- sugar -= 10;
- lemons--;
- ice--;
- cups -= 30;
- fullCups += 30;
- cout << "You make 30 cups of sweet lemonade." << endl;
- type = 1;
- }else{
- cout << "You do not have enough supplies to make sweet lemonade!" << endl;
- }
- break;
- case 2:
- if(sugar >= 5 && lemons >= 1 && ice >= 1 && cups >= 30) {
- sugar -= 5;
- lemons--;
- ice--;
- cups -= 30;
- fullCups += 30;
- cout << "You make 30 cups of normal lemonade." << endl;
- type = 2;
- }else{
- cout << "You do not have enough supplies to make normal lemonade!" << endl;
- }
- break;
- case 3:
- if(sugar >= 5 && lemons >= 2 && ice >= 1 && cups >= 30) {
- sugar -= 5;
- lemons -= 2;
- ice--;
- cups -= 30;
- fullCups += 30;
- cout << "You make 30 cups of sour lemonade." << endl;
- type = 3;
- }else{
- cout << "You do not have enough supplies to make sour lemonade!" << endl;
- }
- break;
- }
- }
- void purchase(int id) {
- switch(id) {
- case 1:
- sugar += 5;
- money -= 2.00;
- cout << "You buy some sugar." << endl;
- break;
- case 2:
- lemons++;
- money -= 5.00;
- cout << "You buy a lemon." << endl;
- break;
- case 3:
- ice++;
- money -= 5.00;
- cout << "You buy a bag of ice." << endl;
- break;
- case 4:
- cups += 30;
- money -= 1.50;
- cout << "You buy a stack of 30 cups." << endl;
- break;
- }
- }
- int main() {system("Color 0E");
- srand(time(0));
- system("cls");for(int x=50; x>0; x--){cout <<endl;Sleep(50);}
- cout <<"Welcome to the Lemonade Stand Game!\nCreated by: REDACTED and REDACTED";
- for(int x=10; x>0; x--){cout <<endl;Sleep(50);}
- system("pause");
- system("cls");
- if(days > DAYS_ALLOWED && money < GOAL) {
- system("cls");
- cout << "You did not meet the required money amount by day " << DAYS_ALLOWED << ", so therefore you lose." << endl;
- }
- if(days > DAYS_ALLOWED && money >= GOAL) {
- system("cls");
- cout << "You met the required money goal! You win!" << endl;
- }
- while(days <= DAYS_ALLOWED) {
- if(days > DAYS_ALLOWED && money >= GOAL) {
- system("cls");
- cout << "You met the required money goal! You win!" << endl;
- break;
- }
- options:
- int choice = 1;
- cout << "Your stock: Money(" << money << "), Sugar(" << sugar << "), Lemons(" << lemons << "), Ice Bags(" << ice << "), Cups(" << cups << ")" << ", Full Cups(" << fullCups << ")" << endl;
- cout << "Day: " << days << ", (1) Visit the general store. (2) Make Lemonade. (3) Start Day" << endl;
- cin >> choice;
- if(choice == 1)
- {
- system("cls");
- goto store;
- }
- else if(choice == 2)
- goto make;
- else if(choice == 3) {
- goto run;
- }
- else
- goto options;
- store:
- displayShop();
- cin >> choice;
- if(choice < 1 || choice > 5) {
- cout << "You have entered in an invalid choice!" << endl;
- goto store;
- }else{
- if(choice == 5)
- {
- system("cls");
- goto options;
- }
- else {
- if(money >= prices[choice - 1]) {
- purchase(choice);
- Sleep(400);
- system("cls");
- }
- else
- cout << "You do not have enough money to buy that!" << endl;
- }
- goto store;
- }
- make:
- displayLemonade();
- cin >> choice;
- if(choice < 1 || choice > 4) {
- cout << "You have entered in an invalid choice!" << endl;
- goto make;
- }
- if(choice == 4){
- system("cls");
- goto options;
- }
- make(choice);
- Sleep(500);
- system("cls");
- goto make;
- run:
- Sleep(SLEEP_TIME);
- system("cls");
- weatherIndex = ran(0, 5);
- cout << "The weather condition for today: " << weather[weatherIndex] << endl;
- cout << "You have until day " << DAYS_ALLOWED << " to stockpile a total of $" << GOAL << "." << endl;
- if(type == 2)
- cout << "What do you want the price for your lemonade to be?\n (1)Cheap ($.50), (2)Normal ($.75), (3)Expensive($1.00)" << endl;
- else
- cout << "What do you want the price for your lemonade to be?\n (1)Cheap ($.75), (2)Normal ($1.00), (3)Expensive($1.25)" << endl;
- cin >> choice;
- chargingPrice = choice;
- double profit = 0;
- int sold = 0;
- if(consecutive >= 50) {
- cout << "Your customers are starting to get bored of the same lemonade flavor!" << endl;
- Sleep(1000);
- }
- for(int customer = 0; customer < 100; customer++) {
- int base = buyChance[type][weatherIndex];
- int percentage = chargingPrice == 1 ? base + 4 : chargingPrice == 2 ? base : base - 11;
- percentage -= consecutive >= 50 ? 10 : 0;
- if(ran(0, 100) <= percentage) {
- if(fullCups == 0) {
- cout << "All of your cups have been sold!\nYou're done for the day, making $" << profit <<"!" << endl;
- cout << "You spend $2.00 on stand maintenance." << endl;
- money -= 2.00;
- days++;
- Sleep(3000);
- system("cls");
- goto options;
- }else{
- fullCups--;
- sold++;
- if(type == 2) {
- money += chargingPrice == 1 ? .50 : chargingPrice == 2 ? .75 : 1.00;
- profit += chargingPrice == 1 ? .50 : chargingPrice == 2 ? .75 : 1.00;
- }else{
- money += chargingPrice == 1 ? .75 : chargingPrice == 2 ? 1.00 : 1.25;
- profit += chargingPrice == 1 ? .75 : chargingPrice == 2 ? 1.00 : 1.25;
- }
- consecutive = customerType == type ? consecutive + 1 : 0;
- customerType = customerType == type ? customerType : type;
- cout << "A customer has bought a cup!\n You now have " << fullCups << " cups of lemonade left." << endl;
- Sleep(SLEEP_TIME);
- }
- }
- }
- cout << "The day is over, and you sold " << sold << " cups of lemonade, netting a profit of $" << profit << "." << endl;
- cout << "You spend $2.00 on stand maintenance." << endl;
- money -= 2.00;
- days++;
- Sleep(3000);
- system("cls");
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement