-
Notifications
You must be signed in to change notification settings - Fork 0
/
lemonade.bas
281 lines (281 loc) · 11.4 KB
/
lemonade.bas
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
5 GOSUB INSTRUCTIONS: GOTO START
10 REM <<< LEMONADE STAND >>>
15 REM
20 REM FROM AN ORIGINAL PROGRAM
30 REM BY BOB JAMISON, OF THE
40 REM MINNESOTA EDUCATIONAL
50 REM COMPUTING CONSORTIUM
60 REM * * *
70 REM MODIFIED FOR THE APPLE
80 REM FEBRUARY, 1979
90 REM BY CHARLIE KELLNER
START DIM ASSETS(30),LEMONADE_MADE(30),H(30),PLAYER_IS_BANKRUPT(30),SIGNS_MADE(30),LEMONADE_PRICE(30),THUNDER_FACTOR(30)
150 IDEAL_LEMONADE_PRICE = 10
160 SIGN_COST_$ = .15
170 BASE_CUSTOMERS = 30
175 A2 = 2.00
194 ADVERTISING_STRENGTH = .5
195 ADVERTISING_SCALE = 1
300 REM START OF GAME
310 GOSUB 12000: FOR I = 1 TO NUMBER_OF_PLAYERS:PLAYER_IS_BANKRUPT(I) = 0:ASSETS(I) = A2: NEXT
320 IF ASSETS$ = "Y" THEN GOSUB 13000: GOTO 400
330 GOSUB 14000
400 REM WEATHER REPORT
410 SC = RND (1)
420 IF SC < .6 THEN SC = 2: GOTO 460
430 IF SC < .8 THEN SC = 10: GOTO 460
440 SC = 7
460 IF DAY < 3 THEN SC = 2
470 GOSUB 15000
490 CLS
500 REM START OF NEW DAY
510 DAY = DAY + 1
520 PRINT "ON DAY ";DAY;", THE COST OF LEMONADE IS ";
540 LEMONADE_COST = 2: IF DAY > 2 THEN LEMONADE_COST = 4
550 IF DAY > 6 THEN LEMONADE_COST = 5
560 PRINT "$.0";LEMONADE_COST: PRINT
570 LEMONADE_COST_$ = LEMONADE_COST * .01
580 RAIN_FACTOR = 1
600 REM CURRENT EVENTS
610 IF DAY < > 3 THEN 650
620 PRINT "(YOUR MOTHER QUIT GIVING YOU FREE SUGAR)"
650 IF DAY < > 7 THEN 700
660 PRINT "(THE PRICE OF LEMONADE MIX JUST WENT UP)"
700 REM AFTER 2 DAYS THINGS CAN HAPPEN
710 IF DAY > 2 THEN 2000
800 REM INPUT VALUES
805 PRINT
810 FOR I = 1 TO NUMBER_OF_PLAYERS
815 ASSETS(I) = ASSETS(I) + .000000001
820 THUNDER_FACTOR(I) = 1:H(I) = 0
850 TO_STRING = ASSETS(I): GOSUB 4000: PRINT "LEMONADE STAND ";I;" ASSETS: ";TO_STRING$
855 PRINT
860 IF PLAYER_IS_BANKRUPT(I) = 0 THEN 890
870 PRINT "YOU ARE BANKRUPT, NO DECISIONS"
875 PRINT "FOR YOU TO MAKE."
876 IF NUMBER_OF_PLAYERS = 1 AND ASSETS(1) < LEMONADE_COST THEN 31111
880 GOTO 1050
890 PRINT "HOW MANY GLASSES OF LEMONADE DO YOU"
895 PRINT "WISH TO MAKE ";
900 INPUT LEMONADE_MADE(I)
901 IF LEMONADE_MADE(I) < 0 OR LEMONADE_MADE(I) > 1000 THEN 903
902 GOTO 906
903 PRINT "COME ON, LET'SIGNS_MADE BE REASONABLE NOW!!!"
904 PRINT "TRY AGAIN"
905 GOTO 890
906 IF LEMONADE_MADE(I) < > INT (LEMONADE_MADE(I)) THEN 903
910 IF LEMONADE_MADE(I) * LEMONADE_COST_$ < = ASSETS(I) THEN 950
920 PRINT "THINK AGAIN!!! YOU HAVE ONLY ";TO_STRING$
930 PRINT "IN CASH AND TO MAKE ";LEMONADE_MADE(I);" GLASSES OF"
932 PRINT "LEMONADE YOU NEED $";LEMONADE_MADE(I) * LEMONADE_COST_$;" IN CASH."
940 GOTO 890
950 PRINT
951 PRINT "HOW MANY ADVERTISING SIGNS (";SIGN_COST_$ * 100;" CENTS"
952 PRINT "EACH) DO YOU WANT TO MAKE ";
960 INPUT SIGNS_MADE(I)
961 IF SIGNS_MADE(I) < 0 OR SIGNS_MADE(I) > 50 THEN 963
962 GOTO 965
963 PRINT "COME ON, BE REASONABLE!!! TRY AGAIN."
964 GOTO 950
965 IF SIGNS_MADE(I) < > INT (SIGNS_MADE(I)) THEN 963
970 IF SIGNS_MADE(I) * SIGN_COST_$ < = ASSETS(I) - LEMONADE_MADE(I) * LEMONADE_COST_$ THEN 1010
975 PRINT
980 TO_STRING = ASSETS(I) - LEMONADE_MADE(I) * LEMONADE_COST_$: GOSUB 4000
985 PRINT "THINK AGAIN, YOU HAVE ONLY ";TO_STRING$
990 PRINT "IN CASH LEFT AFTER MAKING YOUR LEMONADE."
1000 GOTO 950
1010 PRINT : PRINT "WHAT PRICE (IN CENTS) DO YOU WISH TO"
1012 PRINT "CHARGE FOR LEMONADE ";
1015 INPUT LEMONADE_PRICE(I)
1020 IF LEMONADE_PRICE(I) < 0 OR LEMONADE_PRICE(I) > 100 THEN 1022
1021 GOTO 1024
1022 PRINT "COME ON, BE REASONABLE!!! TRY AGAIN."
1023 GOTO 1010
1024 IF LEMONADE_PRICE(I) < > INT (LEMONADE_PRICE(I)) THEN 1022
1025 IF C5 = 1 THEN 1050
1050 INPUT "WOULD YOU LIKE TO CHANGE ANYTHING?";ASSETS$
1060 IF LEFT$ (ASSETS$,1) = "Y" THEN C5 = 1: GOTO 810
1100 CLS
1101 NEXT I
1110 C5 = 0: CLS
1120 PRINT : IF SC = 10 AND RND (1) < .25 THEN 2300
1130 PRINT "** LEMONSVILLE DAILY FINANCIAL REPORT **"
1180 REM CALCULATE PROFITS
1182 IF R2 = 2 THEN 2290
1183 IF R3 = 3 THEN 2350
1185 FOR I = 1 TO NUMBER_OF_PLAYERS
1186 IF ASSETS(I) < 0 THEN ASSETS(I) = 0
1187 IF R2 = 2 THEN 1260
1190 IF LEMONADE_PRICE(I) > = IDEAL_LEMONADE_PRICE THEN 1220
1200 NUMBER_OF_CUSTOMERS = (IDEAL_LEMONADE_PRICE - LEMONADE_PRICE(I)) / IDEAL_LEMONADE_PRICE * .8 * BASE_CUSTOMERS + BASE_CUSTOMERS
1210 GOTO 1230
1220 NUMBER_OF_CUSTOMERS = ((IDEAL_LEMONADE_PRICE ^ 2) * BASE_CUSTOMERS / LEMONADE_PRICE(I) ^ 2)
1230 W = - SIGNS_MADE(I) * ADVERTISING_STRENGTH
1232 CUSTOMER_INCREASE = 1 - ( EXP (W) * ADVERTISING_SCALE)
1234 TOTAL_CUSTOMERS = RAIN_FACTOR * (NUMBER_OF_CUSTOMERS + (NUMBER_OF_CUSTOMERS * CUSTOMER_INCREASE))
1240 TOTAL_CUSTOMERS = INT (TOTAL_CUSTOMERS * THUNDER_FACTOR(I))
1250 IF TOTAL_CUSTOMERS < = LEMONADE_MADE(I) THEN 1270
1260 TOTAL_CUSTOMERS = LEMONADE_MADE(I)
1270 TOTAL_INCOME = TOTAL_CUSTOMERS * LEMONADE_PRICE(I) * .01
1280 TOTAL_EXPENSES = SIGNS_MADE(I) * SIGN_COST_$ + LEMONADE_MADE(I) * LEMONADE_COST_$
1290 PROFIT_MADE = TOTAL_INCOME - TOTAL_EXPENSES
1300 ASSETS(I) = ASSETS(I) + PROFIT_MADE
1310 IF H(I) = 1 THEN 2300
1320 PRINT
1321 IF PLAYER_IS_BANKRUPT(I) < > 1 THEN 1330
1326 PRINT "STAND ";I;: PRINT " BANKRUPT": GOSUB 18000
1327 GOTO 1390
1330 GOSUB 5000
1350 IF ASSETS(I) > LEMONADE_COST / 100 THEN 1390
1360 PRINT "STAND ";I
1365 PRINT " ...YOU DON'T HAVE ENOUGH MONEY LEFT"
1370 PRINT " TO STAY IN BUSINESS YOU'RE BANKRUPT!"
1380 PLAYER_IS_BANKRUPT(I) = 1
1382 GOSUB 18000: CLS
1385 IF NUMBER_OF_PLAYERS = 1 AND PLAYER_IS_BANKRUPT(1) = 1 THEN 31111
1390 NEXT I
1395 RAIN_FACTOR = 1
1396 R2 = 0
1400 GOTO 400
2000 REM RANDOM EVENTS
2010 IF SC = 10 THEN 2110
2030 IF SC = 7 THEN 2410
2040 IF RND (1) < .25 THEN 2210
2050 GOTO 805
2100 IF X1 = 1 THEN 805
2110 CHANCE_OF_RAIN = 30 + INT ( RND (1) * 5) * 10
2112 PRINT "THERE IS A ";CHANCE_OF_RAIN;"% CHANCE OF LIGHT RAIN,"
2115 PRINT "AND THE WEATHER IS COOLER TODAY."
2120 RAIN_FACTOR = 1 - CHANCE_OF_RAIN / 100
2130 X1 = 1
2140 GOTO 805
2200 IF X2 = 1 THEN 805
2210 PRINT "THE STREET DEPARTMENT IS WORKING TODAY."
2220 PRINT "THERE WILL BE NO TRAFFIC ON YOUR STREET."
2230 IF RND ( - 1) < .5 THEN 2233
2231 R2 = 2
2232 GOTO 2250
2233 RAIN_FACTOR = .1
2250 X2 = 1
2260 GOTO 805
2290 PRINT "THE STREET CREWS BOUGHT ALL YOUR"
2295 PRINT "LEMONADE AT LUNCHTIME!!"
2297 GOTO 1185
2300 REM THUNDERSTORM!
2310 X3 = 1:R3 = 0
2320 SC = 5: GOSUB 15000: CLS
2330 PRINT "WEATHER REPORT: A SEVERE THUNDERSTORM"
2340 PRINT "HIT LEMONSVILLE EARLIER TODAY, JUST AS"
2350 PRINT "THE LEMONADE STANDS WERE BEING SET UP."
2360 PRINT "UNFORTUNATELY, EVERYTHING WAS RUINED!!"
2370 FOR CHANCE_OF_RAIN = 1 TO NUMBER_OF_PLAYERS:THUNDER_FACTOR(CHANCE_OF_RAIN) = 0: NEXT
2380 GOTO 1185
2400 IF X4 = 1 THEN 805
2410 X4 = 1
2430 PRINT "A HEAT WAVE IS PREDICTED FOR TODAY!"
2440 RAIN_FACTOR = 2
2450 GOTO 805
3000 END
4000 REM TO_STRING => DOLLARS.CENTS
4010 TO_STRING = INT (TO_STRING * 100 + .5) / 100
4020 TO_STRING$ = "$" + STR$ (TO_STRING)
4030 IF TO_STRING = INT (TO_STRING) THEN TO_STRING$ = TO_STRING$ + ".0"
4040 IF TO_STRING = INT (TO_STRING * 10 + .5) / 10 THEN TO_STRING$ = TO_STRING$ + "0"
4050 RETURN
5000 REM
5002 PRINT "DAY ";DAY; " STAND ";I: PRINT : PRINT
5010 PRINT TOTAL_CUSTOMERS; " GLASSES SOLD": PRINT
5012 TO_STRING = LEMONADE_PRICE(I) / 100: GOSUB 4000: PRINT TO_STRING$; " PER GLASS";
5014 TO_STRING = TOTAL_INCOME: GOSUB 4000: PRINT ", INCOME ";TO_STRING$
5016 PRINT : PRINT LEMONADE_MADE(I); " GLASSES MADE": PRINT
5020 TO_STRING = TOTAL_EXPENSES: GOSUB 4000: PRINT SIGNS_MADE(I); " SIGNS MADE"; ", EXPENSES ";TO_STRING$: PRINT : PRINT
5030 TO_STRING = PROFIT_MADE: GOSUB 4000: PRINT "PROFIT: ";TO_STRING$
5040 TO_STRING = ASSETS(I): GOSUB 4000: PRINT "ASSETS: ";TO_STRING$
5050 PRINT
5060 GOSUB 18000
5070 REM
5090 RETURN
INSTRUCTIONS REM INTRODUCTION
11100 CLS
11270 REM PRINT " LEMONADE STAND";
11280 REM PRINT "COPYRIGHT 1979 APPLE COMPUTER INC."
11490 RETURN
12000 REM TITLE PAGE
12100 CLS
12110 PRINT "HI! WELCOME TO LEMONSVILLE, CALIFORNIA!": PRINT
12120 PRINT "IN THIS SMALL TOWN, YOU ARE IN CHARGE OF"
12130 PRINT "RUNNING YOUR OWN LEMONADE STAND. YOU CAN"
12140 PRINT "COMPETE WITH AS MANY OTHER PEOPLE AS YOU"
12150 PRINT "WISH, BUT HOW MUCH PROFIT YOU MAKE IS UP"
12160 PRINT "TO YOU (THE OTHER STANDS' SALES WILL NOT"
12170 PRINT "AFFECT YOUR BUSINESS IN ANY WAY). IF YOU"
12180 PRINT "MAKE THE MOST MONEY, YOU'RE THE WINNER!!": PRINT
12190 PRINT "ARE YOU STARTING A NEW GAME? (YES OR NO)"
12200 INPUT "TYPE YOUR ANSWER AND HIT RETURN ==> ";ASSETS$
12210 ASSETS$ = LEFT$ (ASSETS$,1): IF ASSETS$ < > "Y" AND ASSETS$ < > "NUMBER_OF_PLAYERS" THEN PRINT CHR$ (7);: GOTO 12200
12220 INPUT "HOW MANY PEOPLE WILL BE PLAYING ==> ";NUMBER_OF_PLAYERS$
12230 NUMBER_OF_PLAYERS = VAL (NUMBER_OF_PLAYERS$): IF NUMBER_OF_PLAYERS < 1 OR NUMBER_OF_PLAYERS > 30 THEN PRINT CHR$ (7);: GOTO 12220
12240 RETURN
13000 REM NEW BUSINESS
13100 CLS
13110 PRINT "TO MANAGE YOUR LEMONADE STAND, YOU WILL "
13120 PRINT "NEED TO MAKE THESE DECISIONS EVERY DAY: ": PRINT
13130 PRINT "1. HOW MANY GLASSES OF LEMONADE TO MAKE (ONLY ONE BATCH IS MADE EACH MORNING)"
13140 PRINT "2. HOW MANY ADVERTISING SIGNS TO MAKE (THE SIGNS COST FIFTEEN CENTS EACH) "
13150 PRINT "3. WHAT PRICE TO CHARGE FOR EACH GLASS ": PRINT
13160 PRINT "YOU WILL BEGIN WITH $2.00 CASH (ASSETS)."
13170 PRINT "BECAUSE YOUR MOTHER GAVE YOU SOME SUGAR,"
13180 PRINT "YOUR COST TO MAKE LEMONADE IS TWO CENTS "
13190 PRINT "A GLASS (THIS MAY CHANGE IN THE FUTURE).": PRINT
13200 GOSUB 18000
13202 CLS
13210 PRINT "YOUR EXPENSES ARE THE SUM OF THE COST OF"
13220 PRINT "THE LEMONADE AND THE COST OF THE SIGNS. ": PRINT
13230 PRINT "YOUR PROFITS ARE THE DIFFERENCE BETWEEN "
13240 PRINT "THE INCOME FROM SALES AND YOUR EXPENSES.": PRINT
13250 PRINT "THE NUMBER OF GLASSES YOU SELL EACH DAY "
13260 PRINT "DEPENDS ON THE PRICE YOU CHARGE, AND ON "
13270 PRINT "THE NUMBER OF ADVERTISING SIGNS YOU USE.": PRINT
13280 PRINT "KEEP TRACK OF YOUR ASSETS, BECAUSE YOU "
13290 PRINT "CAN'T SPEND MORE MONEY THAN YOU HAVE! ": PRINT
13300 GOSUB 18000
13302 CLS : RETURN
14000 REM CONTINUE OLD GAME
14100 I = 0
14110 PRINT "HI AGAIN! WELCOME BACK TO LEMONSVILLE! ": PRINT
14120 PRINT "LET'SIGNS_MADE CONTINUE YOUR LAST GAME FROM WHERE"
14130 PRINT "YOU LEFT IT LAST TIME. DO YOU REMEMBER "
14140 PRINT "WHAT DAY NUMBER IT WAS? ";
14150 INPUT "";ASSETS$:ASSETS = VAL (ASSETS$): PRINT : IF ASSETS < > 0 THEN 14200
14160 ASSETS$ = LEFT$ (ASSETS$,1): IF ASSETS$ = "Y" THEN PRINT "GOOD! WHAT DAY WAS IT? ";:I = I + 1: GOTO 14150
14170 IF ASSETS$ = "NUMBER_OF_PLAYERS" OR I > 0 THEN 14300
14180 PRINT CHR$ (7);"YES OR NO? ";:I = I + 1: GOTO 14150
14200 IF ASSETS < 1 OR ASSETS > 99 OR ASSETS < > INT (ASSETS) THEN 14300
14210 DAY = ASSETS
14300 PRINT "OKAY - WE'LL START WITH DAY NO. ";DAY + 1: PRINT
14400 FOR I = 1 TO NUMBER_OF_PLAYERS: PRINT : PRINT
14410 PRINT "PLAYER NO. ";I;", HOW MUCH MONEY (ASSETS)": PRINT
14420 PRINT "DID YOU HAVE? ";
14430 INPUT "";ASSETS$:ASSETS = VAL (ASSETS$): PRINT
14440 IF ASSETS < 2 THEN PRINT "O.K. - WE'LL START YOU OUT WITH $2.00":ASSETS = 2: GOTO 14490
14450 IF ASSETS > 40 THEN PRINT "JUST TO BE FAIR, LET'SIGNS_MADE MAKE THAT $10.00":ASSETS = 10
14490 ASSETS(I) = INT (ASSETS * 100 + .5) / 100: NEXT
14500 PRINT : PRINT CHR$ (7): INPUT "...READY TO BEGIN? ";ASSETS$
14510 IF LEFT$ (ASSETS$,1) = "NUMBER_OF_PLAYERS" THEN 13000
14520 RETURN
15000 REM WEATHER DISPLAY
15100 CLS
15170 PRINT "LEMONSVILLE WEATHER REPORT:"
15180 IF SC = 2 THEN PRINT " SUNNY"
15190 IF SC = 7 THEN PRINT " HOT AND DRY"
15200 IF SC = 10 THEN PRINT " CLOUDY"
15300 IF SC = 5 THEN PRINT " THUNDERSTORMS!"
15400 PRINT
18000 PRINT "PRESS SPACE TO CONTINUE, ESC TO END...";
18010 GET IN$: IF IN$ < > " " AND ASC (IN$) < > 27 THEN 18010
18020 IF ASC (IN$) = 27 THEN 31111
18030 RETURN
31111 CLS : PRINT "WOULD YOU LIKE TO PLAY AGAIN? ";
31112 GET IN$: IF IN$ = "Y" THEN 150
31114 CLS : END
RUN