1. Create a new project in BlueJ. 2. Create a class named LemonadeStand. 3. Create all methods and fields as defined in the UML diagram shown at the end of this document. create the following elds in your LemonadeStand class: ˆ lemons  the number of lemons you have to make lemonade. ˆ gallonsOfWater  the number of gallons of water you have to make lemonade. ˆ cupsOfSugar  the number of cups of sugar you have to make lemonade. ˆ emptyGlasses  the number of empty glasses you have. ˆ price  the price you are charging for one glass of lemonade. ˆ glassesOfLemonade  the number of full glasses of lemonade that are ready to sell. ˆ income  the amount of income earned since starting to sell lemonade. 7. Make your accessors return eld values. Make your mutators set the eld values from their parameter variables. 8. Make the no-arg constructor set all elds to 0. 9. Make the constructor with parameter variables do the following: ˆ set each eld using its corresponding parameter variable. ˆ set glassesOfLemonade to 0. ˆ set income to 0. (Hint: How many parameter variables does your constructor need?) 10. Modify makeLemonade to make one batch of lemonade according to the following recipe: ˆ Squeeze 6 lemons (decrease lemons) ˆ Mix with 1 gallon of water (decrease gallonsOfWater) ˆ Stir in 1 cup of sugar (decrease cupsOfSugar) ˆ Makes 8 glasses of lemonade (decrease emptyGlasses, increase glassesOfLemonade) ˆ Return the number of glasses made. (Simply return 0 for now. Don't worry about running out of ingredients for now.) 11. Make sellLemonade do the following: ˆ Sell 1 glass of lemonade (decrease glassesOfLemonade by 1) ˆ Take in money (increase income by the price of 1 glass of lemonade) ˆ Return the number of glasses sold (Simply return 0 for now. Don't worry about running out of glasses of lemonade for now.) 12. Modify sellMoreLemonade: Don't worry about this method for now; it is completed in later activities. 13. Now, how can you test your lemonade stand? What would happen if a main method containing the following code were executed? LemonadeStand lemonadeStand = new LemonadeStand(15, 3, 4, 20, 1.5); What does the 15 mean? What about 3? 4? 20? 1.5? If you followed the above code with the following, what would be printed? lemonadeStand.makeLemonade(); System.out.println(lemonadeStand.getLemons()); Try it. That is, create a main method containing the above code and run it. Then print gallonsOfWater, cupsOfSugar, and glassesOfLemonade. 15. Put three calls to lemonadeStand.sellLemonade(); in your main method below the code you added above. What elds do you expect to change? Did they change correctly? Use println to make sure the values are exactly what you expected.

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter6: Managing Multiple Worksheets And Workbooks
Section: Chapter Questions
Problem 2.12CP
icon
Related questions
Question

1. Create a new project in BlueJ.
2. Create a class named LemonadeStand.
3. Create all methods and fields as defined in the UML diagram shown at the end of this document.

create the following elds in your LemonadeStand class:
ˆ lemons  the number of lemons you have to make lemonade.
ˆ gallonsOfWater  the number of gallons of water you have to make lemonade.
ˆ cupsOfSugar  the number of cups of sugar you have to make lemonade.
ˆ emptyGlasses  the number of empty glasses you have.
ˆ price  the price you are charging for one glass of lemonade.
ˆ glassesOfLemonade  the number of full glasses of lemonade that are ready to sell.
ˆ income  the amount of income earned since starting to sell lemonade.
7. Make your accessors return eld values. Make your mutators set the eld values from their parameter
variables.
8. Make the no-arg constructor set all elds to 0.
9. Make the constructor with parameter variables do the following:
ˆ set each eld using its corresponding parameter variable.
ˆ set glassesOfLemonade to 0.
ˆ set income to 0.
(Hint: How many parameter variables does your constructor need?)
10. Modify makeLemonade to make one batch of lemonade according to the following recipe:
ˆ Squeeze 6 lemons (decrease lemons)
ˆ Mix with 1 gallon of water (decrease gallonsOfWater)
ˆ Stir in 1 cup of sugar (decrease cupsOfSugar)
ˆ Makes 8 glasses of lemonade (decrease emptyGlasses, increase glassesOfLemonade)
ˆ Return the number of glasses made. (Simply return 0 for now. Don't worry about running out of
ingredients for now.)
11. Make sellLemonade do the following:
ˆ Sell 1 glass of lemonade (decrease glassesOfLemonade by 1)
ˆ Take in money (increase income by the price of 1 glass of lemonade)
ˆ Return the number of glasses sold (Simply return 0 for now. Don't worry about running out of
glasses of lemonade for now.)
12. Modify sellMoreLemonade: Don't worry about this method for now; it is completed in later activities.
13. Now, how can you test your lemonade stand? What would happen if a main method containing the
following code were executed?
LemonadeStand lemonadeStand = new LemonadeStand(15, 3, 4, 20, 1.5);
What does the 15 mean? What about 3? 4? 20? 1.5?
If you followed the above code with the following, what would be printed?
lemonadeStand.makeLemonade();
System.out.println(lemonadeStand.getLemons());
Try it. That is, create a main method containing the above code and run it. Then print gallonsOfWater,
cupsOfSugar, and glassesOfLemonade.
15. Put three calls to
lemonadeStand.sellLemonade();
in your main method below the code you added above. What elds do you expect to change? Did they
change correctly? Use println to make sure the values are exactly what you expected. 

==
Course: CS1440 X
New folder Unit 5
4 of 4
47°F
Raining now
CS1440 Lemona X
Q
ShapesActivities X
https://asulearn.appstate.edu/pluginfile.php/3321282/mod_resource/content/9/LemonadeStand Prelab.pdf
Quiz Questio...
Unit 5 Quiz Questio... A Course Catalog - A... Q A&P of Hearing Fla...
Homework 3 - R X
:
-lemons int.
-gallonsOfWater: int
-cupsOfSugar: int
-emptyGlasses int
-glassesOfLemonade int
-price: double
-income: double
Get Homework X
Communication an...
+
▬▬▬
■
O
LemonadeStand
+setPrice(newPrice: double): void
+set Income(newIncome: double): void
+LemonadeStand()
+LemonadeStand(init Lemons: int, initGallonsOfWater: int,
init CupsOfSugar: int, initEmptyGlasses int, initPrice: double)
+get Lemons(): int
+getGallonsOfWater(): int
+getCupsOfSugar(): int
+getEmptyGlasses(): int
+getGlassesOfLemonade(): int
+getPrice(): double
+getIncome(): double
+set Lemons(newLemons: int) : void
+set GallonsOfWater(new GallonsOfWater: int) : void
+set CupsOfSugar(newCupsOfSugar: int) : void
+set Empty Glasses (newEmpty Glasses: int) : void
+set GlassesOfLemonade(new GlassesOfLemonade int) : void
+makeLemonade(): int
+sellLemonade(): int
+sellMoreLemonade(requestedGlasses: int): int
Success Confirm X R Decimal to Binar X +
M
SLP 261 Final Study... C Week 2: Tongue, Ve...
CDA
o
Sh
A
0
4) O
X
"O
Other favorites
8 7 {03
in
9:27 PM
9/30/2022
Transcribed Image Text:== Course: CS1440 X New folder Unit 5 4 of 4 47°F Raining now CS1440 Lemona X Q ShapesActivities X https://asulearn.appstate.edu/pluginfile.php/3321282/mod_resource/content/9/LemonadeStand Prelab.pdf Quiz Questio... Unit 5 Quiz Questio... A Course Catalog - A... Q A&P of Hearing Fla... Homework 3 - R X : -lemons int. -gallonsOfWater: int -cupsOfSugar: int -emptyGlasses int -glassesOfLemonade int -price: double -income: double Get Homework X Communication an... + ▬▬▬ ■ O LemonadeStand +setPrice(newPrice: double): void +set Income(newIncome: double): void +LemonadeStand() +LemonadeStand(init Lemons: int, initGallonsOfWater: int, init CupsOfSugar: int, initEmptyGlasses int, initPrice: double) +get Lemons(): int +getGallonsOfWater(): int +getCupsOfSugar(): int +getEmptyGlasses(): int +getGlassesOfLemonade(): int +getPrice(): double +getIncome(): double +set Lemons(newLemons: int) : void +set GallonsOfWater(new GallonsOfWater: int) : void +set CupsOfSugar(newCupsOfSugar: int) : void +set Empty Glasses (newEmpty Glasses: int) : void +set GlassesOfLemonade(new GlassesOfLemonade int) : void +makeLemonade(): int +sellLemonade(): int +sellMoreLemonade(requestedGlasses: int): int Success Confirm X R Decimal to Binar X + M SLP 261 Final Study... C Week 2: Tongue, Ve... CDA o Sh A 0 4) O X "O Other favorites 8 7 {03 in 9:27 PM 9/30/2022
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage