/* http://www.mrwadlo.com */ #include #include #include #include #define MAX 48 int cust[MAX][4]; int pos[MAX][2]; int recipe[3]; unsigned int supply[4]; int stuff[21][3]; float store[4][3]; float price = 0.25; int temp; int popularity = 1; int shown = 0; char serving = 'n'; int day = 0; long one_sec; float cash = 20.000; float net = 20.000; float change = 0.000; unsigned int RobotLimits[4] = { 500,500,500,500 }; int RobotCompare = 0; int RobotAdjust = 1; int RobotRunning = 0; int RobotRecipe[3]; void makecustomers(); char startday(); void sim(); void editrecipe(int com); int randomize(int start, int end); void drawboard(); void temps(int hour); int thirsty(int customer); void displaystatus(char array[]); void displaycash(); void buy(); void displaysupply(); void kmart(); void decay(); void incay(); void makestuff(); void setstore(); void displaystuff(int num, int line); int fullcart(); void define(int line, char array[]); void donate(); void mainhelp(); void displaynormal(); void robot(); unsigned int get64k(int x, int y); void autobuy(); void calc_time(); void count_100ths(int hund); void defineitem(int item); void recipehandy(); void reciperestore(); void main() { char ext = '?'; clrscr(); textcolor(7); calc_time(); makecustomers(); drawboard(); makestuff(); editrecipe(0); displaycash(); displaysupply(); ext = startday(); while ( ext != 'q' && ext != 'Q' ) { sim(); if ( RobotRunning == 0 ) ext = startday(); else autobuy(); } } void calc_time() { time_t time1; time1 = time(NULL); gotoxy(30,13); printf("Calculating CPU Speed..."); while( time(NULL) == time1 ) ; time1 = time(NULL); while( time(NULL) < (time1 + 2) ) { one_sec++; printf(" \b"); } clrscr(); one_sec /= 2; } void count_100ths(int hund) { long i = 0; time_t time1; gotoxy (1,25); while ( i < ( one_sec / 100 * hund ) ) { printf(" \b"); time1 = time(NULL); i++; } } void makecustomers() { int i; srand((unsigned int)time((time_t *)NULL)); for ( i=0 ; i= '0' && com <= '9') || com == '-' || com == '+' ) { editrecipe(com); } else if ( com == 's' || com == 'S' ) { kmart(); } else if ( com == 'r' || com == 'R' ) { if ( stuff[20][2] == 2 || stuff[20][2] == 4 ) { robot(); } } else if ( com == 'h' || com == 'H' ) mainhelp(); else if ( com == 'q' || com == 'Q' ) { displaystatus("Are you sure you want to quit? [Y]es [N]o"); do { com = getch(); } while ( com != 'y' && com != 'Y' && com != 'n' && com != 'N'); if ( com == 'y' || com == 'Y' ) com = 'Q'; else displaystatus("[O]pen [S]tore [H]elp [Q]uit"); } } while ( com != 'Q' && com != 'O' && com != 'o' && RobotRunning == 0 ); return com; } void sim() { int hour=6, min=59; int i,j; char ins = '?'; int person_number = 0; int closed = 0; for ( i=0 ; i 59 ) { min = 0; hour++; temps(hour); } if ( closed == 0 && min%15 == 0 ) { gotoxy(25,3); textcolor(12); for ( i=7 ; i<=hour ; i++ ) cprintf("%c",219); textcolor(14); for ( ; i <= 19 ; i++ ) { cprintf("%c",219); } textcolor(7); person_number = thirsty(person_number); if ( RobotRunning == 1 && RobotAdjust == 1 ) recipehandy(); displaycash(); displaysupply(); } if ( kbhit() ) { if ( RobotRunning == 0 ) { ins = getch(); if ( ins == 'c' || ins == 'C' ) { closed = 1; displaystatus(" "); gotoxy(25,3); cprintf(" Gone Fishin'"); } if ( ( ins > '0' && ins <='9' ) || ins == '-' || ins == '+' ) editrecipe(ins); } else { ins = getch(); if ( ins == 's' || ins == 'S' ) { RobotRunning = 0; for ( j=7 ; j<23 ; j++ ) { gotoxy(2,j); for ( i=2 ; i<45 ; i++ ) printf(" "); } displaystatus("[C]lose"); } } } } gotoxy(4,2); textcolor(10); cprintf("%c",178); textcolor(7); gotoxy(3,3); printf(" "); gotoxy(25,3); cprintf(" CLOSED "); if ( RobotRunning == 1 && RobotAdjust == 1 ) reciperestore(); decay(); incay(); displaysupply(); } int randomize(int start, int end) { int number; number = (( rand() + time(NULL) ) % (end - start + 1)) + start; return number; } void editrecipe(int com) { if ( com == '7' && recipe[0] < 9 ) recipe[0]++; /* ice++ */ else if ( com == '1' && recipe[0] > 0 ) recipe[0]--; /* ice-- */ else if ( com == '8' && recipe[1] < 9 ) recipe[1]++; /* lemon++ */ else if ( com == '2' && recipe[1] > 0 ) recipe[1]--; /* lemon-- */ else if ( com == '9' && recipe[2] < 9 ) recipe[2]++; /* sugar++ */ else if ( com == '3' && recipe[2] > 0 ) recipe[2]--; /* sugar-- */ else if ( com == '+' && price < 0.999 ) price += .01; else if ( com == '-' && price > 0.010 ) price -= .01; displaysupply(); } void drawboard() { int i; int cash_x = 47; int cash_y = 1; int status_x = 47; int status_y = 19; int street_x = 2; int street_y = 1; for ( i=status_x+1 ; i 0 ) temp -= 1; else if ( change > 38 && temp < 2 ) temp += 1; } else if ( hour != 99 ) { if ( change < 2 && temp > 0 ) temp -= 1; else if ( change > 39 && temp < 2 ) temp += 1; } gotoxy(9,2); printf("Weather "); if ( temp == 0 ) { printf("Cool"); textcolor(11); } else if ( temp == 1 ) { printf("Warm"); textcolor(14); } else { printf("HOT!"); textcolor(12); } gotoxy(18+hour,2); cprintf("%c",219); textcolor(7); } int thirsty(int c) { int temp; int chances; int chances1; int chances2; int chances3; int chances4; int chances5; int advertise = 1; int i; temp = 0; for ( i=0 ; i<20 ; i++ ) { if ( ( stuff[i][2] == 2 || stuff[i][2] == 4 ) && stuff[i][0] == 4 ) /* signs */ { temp++; } } if ( temp >= 2 ) advertise++; temp = 0; for ( i=0 ; i<20 ; i++ ) { if ( ( stuff[i][2] == 2 || stuff[i][2] == 4 ) && stuff[i][0] == 7 ) /* sugar */ { temp++; i = 50; } } for ( i=0 ; i<20 ; i++ ) { if ( ( stuff[i][2] == 2 || stuff[i][2] == 4 ) && stuff[i][0] == 9 ) /* strainer */ { temp++; i = 50; } } if ( temp == 2 ) advertise++; gotoxy(3,3); printf(" "); while ( advertise > 0 ) { chances1 = randomize(0,5 - (popularity*5/MAX) ); chances2 = ( recipe[0] - cust[c][0] ); if ( chances2 < 0 ) chances2 *= -1; chances3 = ( recipe[1] - cust[c][1] ); if ( chances3 < 0 ) chances3 *= -1; chances4 = ( recipe[2] - cust[c][2] ); if ( chances4 < 0 ) chances4 *= -1; chances5 = (((price * 100) - cust[c][3] ) / 5 ); if ( chances5 < 0 ) chances5 = 0; chances = 10 - chances1 - chances2 - chances3 - chances4 - chances5 + temp; if ( chances > 0 && checksupply() == 1 ) { buy(); gotoxy(3+randomize(0,2),3); printf("%c",randomize(1,2)); } advertise--; c++; if ( c >= MAX ) c=0; } return c; } void displaystatus(char array[]) { int i; gotoxy(2,24); for ( i=0 ; i<44 ; i++ ) printf(" "); i=0; while ( array[i] != 0 ) { i++; } i=44-i; i/=2; gotoxy(2+i,24); printf("%s", array); } void displaynormal() { if ( stuff[20][2] == 2 || stuff[20][2] == 4 ) displaystatus("[O]pen [S]tore [R]obot [H]elp [Q]uit"); else displaystatus("[O]pen [S]tore [H]elp [Q]uit"); } void displaycash() { int i,j, counter; gotoxy(57,2); printf("$%.2f ",cash); gotoxy(57,4); printf("$%.2f ",change); gotoxy(57,6); printf("$%.2f ",net); for ( i=8 ; i<18 ; i++ ) { gotoxy(57,i); for ( j=0 ; j<21 ; j++ ) printf(" "); } counter = 0; for ( i=0 ; i<21 ; i++ ) { if ( stuff[i][2] == 2 || stuff[i][2] == 4 ) { gotoxy(57,8+counter); switch ( stuff[i][0] ) { case 1: printf("Picnic Cooler"); break; case 2: printf("Chill Freezer"); break; case 3: printf("Lemon Tree"); break; case 4: printf("%2.2f Lemonade Sign",price); break; case 5: printf("Ice Maker"); break; case 6: printf("Fake Mustash"); break; case 7: printf("Sugar Container"); break; case 8: printf("Dish Wash Supply"); break; case 9: printf("Juice Strainer"); break; case 10: printf("LemonRobot 1.0"); break; } counter++; } if ( counter >= 10 ) i = 50; } } void buy() { cash += price; change += price; net += price; supply[3]--; supply[0] -= recipe[0]; supply[1] -= recipe[1]; supply[2] -= recipe[2]; } int checksupply() { if ( supply[3] < 1 ) return 0; if ( supply[0] < recipe[0] ) return 0; if ( supply[1] < recipe[1] ) return 0; if ( supply[2] < recipe[2] ) return 0; return 1; } void displaysupply() { if ( supply[3] < 1 ) textcolor(12); else textcolor(7); gotoxy(49,24); cprintf("%u ",supply[3]); /* cups */ if ( supply[0] < recipe[0] ) textcolor(12); else textcolor(7); gotoxy(57,24); cprintf("%u ",supply[0]); /* ice */ if ( supply[1] < recipe[1] ) textcolor(12); else textcolor(7); gotoxy(65,24); cprintf("%u ",supply[1]); /* lemon */ if ( supply[2] < recipe[2] ) textcolor(12); else textcolor(7); gotoxy(73,24); cprintf("%u ",supply[2]); /* sugar */ textcolor(7); gotoxy(49,22); printf("$%2.2f", price); gotoxy(59,22); printf("%d", recipe[0]); /* ice */ gotoxy(67,22); printf("%d", recipe[1]); /* lemon */ gotoxy(75,22); printf("%d", recipe[2]); /* sugar */ } void kmart() { int i, j; int status_x = 2; int status_y = 7; char com; int cursor_x = 0; int cursor_y = 0; int counter; for ( i=status_x+1 ; i */ if ( cursor_x == 4 ) gotoxy(status_x+9+(8*cursor_x),status_y+3+(3*cursor_y)); else gotoxy(status_x+7+(8*cursor_x),status_y+3+(3*cursor_y)); printf("%c",17); /* < */ com = getch(); gotoxy(status_x+1+(8*cursor_x),status_y+3+(3*cursor_y)); printf(" "); if ( cursor_x == 4 ) gotoxy(status_x+9+(8*cursor_x),status_y+3+(3*cursor_y)); else gotoxy(status_x+7+(8*cursor_x),status_y+3+(3*cursor_y)); printf(" "); if ( com == 0 ) { com = getch(); switch ( com ) { case 80: if ( cursor_y < 2 ) cursor_y++; break; case 72: if ( cursor_y > 0 ) cursor_y--; break; case 77: if ( cursor_x < 4 ) cursor_x++; break; case 75: if ( cursor_x > 0 ) cursor_x--; break; } } else if ( com == 13 ) { if ( cursor_x == 0 && supply[3] < 64000 ) { if ( cursor_y == 0 && cash >= store[3][0] ) { supply[3] += 25; cash -= store[3][0]; } else if ( cursor_y == 1 && cash >= store[3][1] ) { supply[3] += 50; cash -= store[3][1]; } else if ( cursor_y == 2 && cash >= store[3][2] ) { supply[3] += 100; cash -= store[3][2]; } } else if ( cursor_x == 1 && supply[0] < 64000 ) { if ( cursor_y == 0 && cash >= store[0][0] ) { supply[0] += 100; cash -= store[0][0]; } else if ( cursor_y == 1 && cash >= store[0][1] ) { supply[0] += 200; cash -= store[0][1]; } else if ( cursor_y == 2 && cash >= store[0][2] ) { supply[0] += 500; cash -= store[0][2]; } } else if ( cursor_x == 2 && supply[1] < 64000 ) { if ( cursor_y == 0 && cash >= store[1][0] ) { supply[1] += 5; cash -= store[1][0]; } else if ( cursor_y == 1 && cash >= store[1][1] ) { supply[1] += 10; cash -= store[1][1]; } else if ( cursor_y == 2 && cash >= store[1][2] ) { supply[1] += 16; cash -= store[1][2]; } } else if ( cursor_x == 3 && supply[2] < 64000 ) { if ( cursor_y == 0 && cash >= store[2][0] ) { supply[2] += 16; cash -= store[2][0]; } else if ( cursor_y == 1 && cash >= store[2][1] ) { supply[2] += 32; cash -= store[2][1]; } else if ( cursor_y == 2 && cash >= store[2][1] ) { supply[2] += 80; cash -= store[2][2]; } } else if ( cursor_x == 4 ) { counter = 0; if ( cursor_y == 0 ) { for ( i=0 ; i<21 ; i++ ) { if ( stuff[i][2] == 1 ) counter++; if ( counter == 1 ) { if ( cash >= stuff[i][1] - 0.01 && fullcart() == 0 ) { stuff[i][2] = 4; cash = cash - stuff[i][1] + 0.01; } i = 50; } } } else if ( cursor_y == 1 ) { for ( i=0 ; i<21 ; i++ ) { if ( stuff[i][2] == 1 ) counter++; if ( counter == 2 ) { if ( cash >= stuff[i][1] - 0.01 && fullcart() == 0 ) { stuff[i][2] = 4; cash = cash - stuff[i][1] + 0.01; } i = 50; } } } else if ( cursor_y == 2 ) { for ( i=0 ; i<21 ; i++ ) { if ( stuff[i][2] == 1 ) counter++; if ( counter == 3 ) { if ( cash >= stuff[i][1] - 0.01 && fullcart() == 0 ) { stuff[i][2] = 4; cash = cash - stuff[i][1] + 0.01; } i = 50; } } } for ( i=status_y+3 ; iice */ { ice_adv++; } if ( ( stuff[i][2] == 2 || stuff[i][2] == 4 ) && stuff[i][0] == 2 ) /* freezer */ { ice_adv = 3; } if ( ( stuff[i][2] == 2 || stuff[i][2] == 4 ) && stuff[i][0] == 7 ) /* container */ { sug_adv = 1; } if ( ( stuff[i][2] == 2 || stuff[i][2] == 4 ) && stuff[i][0] == 1 ) /* cooler->lemons */ { lem_adv = 1; } } /* ***************************************************** */ if ( ice_adv < 3 ) { if ( ice_adv == 2 ) temp = 1L * supply[0] * randomize(20,30) / 100; /* 20-30% */ else if ( ice_adv == 1 ) temp = 1L * supply[0] * randomize(30,40) / 100; /* 30-40% */ else temp = 1L * supply[0] * randomize(40,60) / 100; /* 40-60% */ if ( supply[0] > 0 && temp < 5 ) temp++; supply[0] = supply[0] - temp; /* ice */ } /* else 0% */ if ( lem_adv == 1 ) temp = supply[1] * randomize(1,10) / 100; else temp = supply[1] * randomize(1,5) / 100; if ( supply[1] > 0 && temp < 15 && randomize(0,1) == 1 ) temp++; supply[1] = supply[1] - temp; /* lemon */ if ( randomize(0,5) == 1 && supply[2] > 0 && sug_adv == 0 ) { temp = supply[2] * randomize(1,5) / 100; if ( supply[2] < 10 ) temp++; supply[2] = supply[2] - temp; /* sugar */ } } void incay() { int i; int cups; cups = (int)change/price; cups--; for ( i=0 ; i<20 ; i++ ) { if ( ( stuff[i][2] == 2 || stuff[i][2] == 4 ) && stuff[i][0] == 3 ) /* trees */ { supply[1] += randomize(4,7); } if ( ( stuff[i][2] == 2 || stuff[i][2] == 4 ) && stuff[i][0] == 5 ) /* ice maker */ { supply[0] += randomize(50,100); } if ( ( stuff[i][2] == 2 || stuff[i][2] == 4 ) && stuff[i][0] == 8 ) { if ( cups > 0 ) supply[3] += randomize(0,cups); } } if ( RobotRunning == 1 ) supply[2] += randomize(9,12); } void makestuff() { int i; for ( i=0 ; i<20 ; i++ ) { stuff[i][0] = randomize(1,9); switch ( stuff[i][0] ) { case 1: stuff[i][1] = randomize(29,31); break; case 2: stuff[i][1] = randomize(280,320); break; case 3: stuff[i][1] = randomize(20,200); break; case 4: stuff[i][1] = randomize(3,10); break; case 5: stuff[i][1] = randomize(150,400); break; case 6: stuff[i][1] = randomize(2,3); break; case 7: stuff[i][1] = randomize(5,30); break; case 8: stuff[i][1] = randomize(30,35); break; case 9: stuff[i][1] = randomize(7,25); break; } stuff[i][2] = 0; } stuff[20][0] = 10; stuff[20][1] = randomize(990,1000); /* AI */ stuff[20][2] = 0; } void setstore() { int i; int num; store[3][0] = 1.0F * randomize(40,60) / 100; store[3][1] = 1.0F * randomize(80,120) / 100; /* cups */ store[3][2] = 1.0F * randomize(160,240) / 100; store[0][0] = 1.0F * randomize(170,190) / 100; store[0][1] = 1.0F * randomize(425,475) / 100; /* ice */ store[0][2] = 1.0F * randomize(850,950) / 100; store[1][0] = 1.0F * randomize(50,150) / 100; store[1][1] = 1.0F * randomize(100,300) / 100; /* lemons */ store[1][2] = 1.0F * randomize(160,480) / 100; store[2][0] = 1.0F * randomize(55,73) / 100; store[2][1] = 1.0F * randomize(110,146) / 100; /* sugar */ store[2][2] = 1.0F * randomize(275,365) / 100; for ( i=0 ; i<21 ; i++ ) { if ( stuff[i][2] == 1 ) stuff[i][2] = 0; else if ( stuff[i][2] == 4 ) stuff[i][2] = 2; } i = 0; while ( i<3 ) { num = randomize(0,20); if ( stuff[num][2] == 0 ) { stuff[num][2] = 1; i++; } } } void displaystuff( int num, int line ) { int i,counter; counter=0; for ( i=0 ; i<21 ; i++ ) { if ( stuff[i][2] == 1 ) { counter++; } if ( counter == num ) { if ( line == 1 ) { switch ( stuff[i][0] ) { case 1: printf("COOLER"); break; case 2: printf("FREEZER"); break; case 3: printf("XL TREE"); break; case 4: printf(" SIGN "); break; case 5: printf("ICEMAKR"); break; case 6: printf("FAKEMUS"); break; case 7: printf(" JAR "); break; case 8: printf("DISHWSH"); break; case 9: printf("STRAINR"); break; case 10: printf(" ROBOT "); break; } } if ( line == 2 ) { printf("$%d.99",stuff[i][1] - 1); } i = 50; } } } int fullcart() { int i, counter; char com; counter = 0; for ( i=0 ; i<21 ; i++ ) { if ( stuff[i][2] == 2 || stuff[i][2] == 4 ) { counter++; } if ( counter == 10 ) { define(1,"You have too many items, would you like"); define(2,"to sell one? "); define(3," "); do { displaystatus("[Y]es [N]o"); com = getch(); displaystatus(" "); if ( com == 'y' || com == 'Y' ) { donate(); return 0; } else if ( com == 'n' || com == 'N' ) return 1; } while ( com != 'y' && com != 'Y' ); } } return 0; /* not full */ } void define(int line, char array[]) { gotoxy(4,18+line); printf("%s", array); } void donate() { int i; int counter = -1; int cursor = 0; char com; define(1,"Select the item you wish to donate "); define(2,"using the up and down arrows. "); define(3,"Press ENTER to donate. "); do { gotoxy(54,8+cursor); printf("%c",16); com = getch(); if ( com == 72 && cursor > 0 ) { gotoxy(54,8+cursor); printf(" "); cursor--; } else if ( com == 80 && cursor < 9 ) { gotoxy(54,8+cursor); printf(" "); cursor++; } } while ( com != 13 ); gotoxy(54,8+cursor); printf(" "); for ( i=0 ; i<21 ; i++ ) { if ( stuff[i][2] == 2 || stuff[i][2] == 4 ) { counter++; } if ( counter == cursor ) { stuff[i][2] = 0; i = 50; } } define(1,"Item donated. Thank you. "); define(2," "); define(3," "); count_100ths(100); displaystatus("[L]eave"); } void mainhelp() { int i,j; gotoxy(3,7); for ( i=3 ; i<44 ; i++ ) printf("%c",205); gotoxy(3,22); for ( i=3 ; i<44 ; i++ ) printf("%c",205); for ( i=8 ; i<22; i++ ) { gotoxy(2,i); printf("%c",186); gotoxy(44,i); printf("%c",186); } gotoxy(2,7); printf("%c",201); gotoxy(2,22); printf("%c",200); gotoxy(44,7); printf("%c",187); gotoxy(44,22); printf("%c",188); /* S E */ gotoxy(4,8); printf("The point of a lemonade stand is to "); gotoxy(4,9); printf("make as much money as fast as possible."); gotoxy(4,10); printf("Open each day by pressing 'O' and if "); gotoxy(4,11); printf("needed close up shop by pressing 'C'. "); gotoxy(4,12); printf("Adjust your secret recipe using the "); gotoxy(4,13); printf("num-pad digits 7-8-9 to increase and "); gotoxy(4,14); printf("1-2-3 to decrease. Change the price per"); gotoxy(4,15); printf("cup using + & -. After every day you "); gotoxy(4,16); printf("can go to the store and buy supplies by"); gotoxy(4,17); printf("pressing 'S'. Remember that you can "); gotoxy(4,18); printf("change your recipe mid-day if you run "); gotoxy(4,19); printf("out of ice/lemons/sugar, but there is "); gotoxy(4,20); printf("no way to serve drinks without cups. "); gotoxy(4,21); printf(" Press any key "); getch(); /* S E */ gotoxy(4,8); printf("Customers enjoy a well mixed glass of "); gotoxy(4,9); printf("lemonade, so a well balanced inventory"); gotoxy(4,10); printf("and recipe is the key to success. As in"); gotoxy(4,11); printf("real life, ice melts, lemons and sugar "); gotoxy(4,12); printf("can go bad. Your cash in hand, gain per"); gotoxy(4,13); printf("day, and net gain can be found in the "); gotoxy(4,14); printf("top right corner. 'Stuff' are items "); gotoxy(4,15); printf("that can improve your sales. These can "); gotoxy(4,16); printf("be bought and donated, but not sold. "); gotoxy(4,17); printf("The goal of this game is to find "); gotoxy(4,18); printf("someone to work FOR you so you can "); gotoxy(4,19); printf("retire in Maui. Help info for items is "); gotoxy(4,20); printf("available in the store. "); gotoxy(4,21); printf("Press any key to continue & good luck! "); /* S E */ getch(); for ( j=7 ; j<23 ; j++ ) { gotoxy(2,j); for ( i=2 ; i<45 ; i++ ) printf(" "); } } void robot() { int i,j; char com; gotoxy(3,7); for ( i=3 ; i<44 ; i++ ) printf("%c",205); gotoxy(3,22); for ( i=3 ; i<44 ; i++ ) printf("%c",205); for ( i=8 ; i<22; i++ ) { gotoxy(2,i); printf("%c",186); gotoxy(44,i); printf("%c",186); } gotoxy(2,7); printf("%c",201); gotoxy(2,22); printf("%c",200); gotoxy(44,7); printf("%c",187); gotoxy(44,22); printf("%c",188); /* S E */ gotoxy(4,8); printf("LemonRobot 1.0 Info: "); gotoxy(4,9); printf("LemonRobot 1.0 is a self-sufficiant "); gotoxy(4,10); printf("system that is able to staff a lemonade"); gotoxy(4,11); printf("stand just like a living person. "); gotoxy(4,12); printf("It can open the stand in the morning, "); gotoxy(4,13); printf("sell lemonade at the set recipe, adjust"); gotoxy(4,14); printf("the recipe if supplies run low, close "); gotoxy(4,15); printf("the stand at night, and buy supplies "); gotoxy(4,16); printf("before the next day. In order to use "); gotoxy(4,17); printf("LemonRobot 1.0, set your recipe "); gotoxy(4,18); printf("accordingly based on the 'Stuff' you "); gotoxy(4,19); printf("have and set the following options. "); gotoxy(4,20); printf("LemonRobot 1.0 converts water to sugar."); gotoxy(4,21); printf(" Press any key "); displaystatus(" "); getch(); gotoxy(4,8); printf("LemonRobot 1.0 Menu: "); gotoxy(4,9); printf(" "); gotoxy(4,10); printf("Set the lower supply limit: "); gotoxy(4,11); printf(" [C]ups [I]ce [L]emons [S]ugar "); gotoxy(4,12); printf(" "); gotoxy(4,13); printf(" "); gotoxy(4,14); printf("Compare [P]rices before buying? "); gotoxy(4,15); printf(" "); gotoxy(4,16); printf(" "); gotoxy(4,17); printf("[A]utomatically adjust recipe when low?"); gotoxy(4,18); printf(" "); gotoxy(4,19); printf(" "); gotoxy(4,20); printf(" [R]un LemonRobot 1.0 "); gotoxy(4,21); printf(" "); displaystatus("[B]ack"); do { gotoxy(6,12); printf("%u",RobotLimits[3]); gotoxy(16,12); printf("%u",RobotLimits[0]); gotoxy(26,12); printf("%u",RobotLimits[1]); gotoxy(36,12); printf("%u",RobotLimits[2]); gotoxy(5,15); if ( RobotCompare == 1 ) printf("Yes"); else printf("No "); gotoxy(5,18); if ( RobotAdjust == 1 ) printf("Yes"); else printf("No "); com = getch(); if ( com == 'r' || com == 'R' ) RobotRunning = 1; else if ( com == 'p' || com == 'P' ) { RobotCompare = ( RobotCompare + 1 ) % 2; } else if ( com == 'a' || com == 'A' ) { RobotAdjust = ( RobotAdjust + 1 ) % 2; } else if ( com == 'c' || com == 'C' ) { RobotLimits[3] = get64k(6,12); } else if ( com == 'i' || com == 'I' ) { RobotLimits[0] = get64k(16,12); } else if ( com == 'l' || com == 'L' ) { RobotLimits[1] = get64k(26,12); } else if ( com == 's' || com == 'S' ) { RobotLimits[2] = get64k(36,12); } } while ( com != 'b' && com != 'B' && com != 'r' && com != 'R' ); if ( com == 'b' || com == 'B' ) { for ( j=7 ; j<23 ; j++ ) { gotoxy(2,j); for ( i=2 ; i<45 ; i++ ) printf(" "); } displaynormal(); } else { gotoxy(10,20); printf("LemonRobot 1.0 is running."); displaystatus("[S]top"); } } unsigned int get64k(int x, int y) { char com; char array[6]; unsigned int number = 0; int i,j; do { gotoxy(x,y); printf(" \b\b\b\b\b"); i=0; do { com = getch(); if ( com >= '0' && com <= '9' && i<5 ) { printf("%c", com); array[i] = com; i++; } else if ( com == '\b' && i>0 ) { printf("\b \b"); i--; } } while ( com != 13 || i == 0 ); for ( j=0 ; j 64000 ); return number; } void autobuy() { float price0; float price1; float price2; float price3; if ( RobotCompare == 1 ) { price0 = randomize(170,185); price1 = randomize(50,145); price2 = randomize(55,68); price3 = randomize(40,55); } else { price0 = randomize(175,190); price1 = randomize(55,150); price2 = randomize(60,73); price3 = randomize(45,60); } price0 = 1.0F * price0 / 100; price1 = 1.0F * price1 / 100; price2 = 1.0F * price2 / 100; price3 = 1.0F * price3 / 100; while ( supply[3] < RobotLimits[3] && price3 < change ) { cash -= price3; change -= price3; supply[3] += 25; } while ( supply[0] < RobotLimits[0] && price0 < change ) { cash -= price0; change -= price0; supply[0] += 100; } while ( supply[1] < RobotLimits[1] && price1 < change ) { cash -= price1; change -= price1; supply[1] += 5; } while ( supply[2] < RobotLimits[2] && price2 < change ) { cash -= price2; change -= price2; supply[2] += 16; } } void defineitem(int item) { switch ( item ) { case 0: define(1," "); define(2," "); define(3," "); break; case 1: define(1,"The Picnic Cooler is an inexpensive way"); define(2,"to prevent the sun from slowing your "); define(3,"progress. Available in red and blue. "); break; case 2: define(1,"A Chill Freezer is essential for "); define(2,"keeping ice cold. This top of the line "); define(3,"freezer has a lifetime warrenty. "); break; case 3: define(1,"A Lemon Tree can produce lemons ready "); define(2,"to be picked on a daily basis. More "); define(3,"than one source of lemons is key. "); break; case 4: define(1,"Lemonade Signs can let future customers"); define(2,"know that you are open for buisness, as"); define(3,"well as how much you charge per cup. "); break; case 5: define(1,"An Ice Maker can produce a large amount"); define(2,"of ice every day. Ice Makers are best "); define(3,"used with freezers. "); break; case 6: define(1,"A Fake Mustash is a sure way to raise "); define(2,"your popularity level. Now available in"); define(3,"handlebar style. "); break; case 7: define(1,"A Sugar Container can keep sugar freash"); define(2,"longer than sitting around in an open "); define(3,"sack as purchased from the store. "); break; case 8: define(1,"Dish Wash Supply can clean cups that "); define(1,"that are left behind by customers. Only"); define(1,"one system can be used at a time. "); break; case 9: define(1,"A Juice Strainer can improve the "); define(2,"quality of your lemonade. Your pulpy "); define(3,"drinks will now be filtered clear. "); break; case 10: define(1,"LemonRobot 1.0 is a rare item that can "); define(2,"staff a lemonade stand on its own. This"); define(3,"robot has several adjustable settings. "); break; case 100: define(1,"Plastic cups are the only way to serve "); define(2,"lemonade. Without cups, your just "); define(3,"showing off your lemonade in the sun. "); break; case 101: define(1,"Ice can be used to cool down drinks and"); define(2,"is well appreicated on a hot day. "); define(3,"Number represents a count of ice cubes."); break; case 102: define(1,"Lemons are the cornerstone of any "); define(2,"lemonade recipe. Number represents "); define(3,"a count of lemon-halves per bag. "); break; case 103: define(1,"Sugar counteracts the sour taste of "); define(2,"lemons to make lemonade a great drink. "); define(3,"Number represents weight in ounces. "); break; } } void recipehandy() { while ( recipe[0] > supply[0] && recipe[0] != 0 ) { recipe[0]--; displaysupply(); } while ( recipe[1] > supply[1] && recipe[1] != 0 ) { recipe[1]--; displaysupply(); } while ( recipe[2] > supply[2] && recipe[2] != 0 ) { recipe[2]--; displaysupply(); } } void reciperestore() { recipe[0] = RobotRecipe[0]; recipe[1] = RobotRecipe[1]; recipe[2] = RobotRecipe[2]; }