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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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. 

The image shows a UML (Unified Modeling Language) class diagram for a class named `LemonadeStand`. This diagram outlines the structure of the `LemonadeStand` class, including its attributes and methods. Here’s a detailed explanation:

### Attributes
- `lemons : int` - Represents the number of lemons available.
- `gallonsOfWater : int` - Represents the gallons of water available.
- `cupsOfSugar : int` - Represents the cups of sugar available.
- `emptyGlasses : int` - Represents the number of empty glasses available.
- `glassesOfLemonade : int` - Represents the number of glasses of lemonade available.
- `price : double` - Represents the price of a glass of lemonade.
- `income : double` - Represents the total income from selling lemonade.

### Methods
- `LemonadeStand()` - Default constructor for initializing a lemonade stand.
- `LemonadeStand(initLemons : int, initGallonsOfWater : int, initCupsOfSugar : int, initEmptyGlasses : int, initPrice : double)` - Parameterized constructor to initialize the lemonade stand with specified amounts.
- `getLemons() : int` - Returns the number of lemons.
- `getGallonsOfWater() : int` - Returns the gallons of water.
- `getCupsOfSugar() : int` - Returns the cups of sugar.
- `getEmptyGlasses() : int` - Returns the number of empty glasses.
- `getGlassesOfLemonade() : int` - Returns the number of glasses of lemonade.
- `getPrice() : double` - Returns the price per glass of lemonade.
- `getIncome() : double` - Returns the total income.
- `setLemons(newLemons : int) : void` - Sets a new value for lemons.
- `setGallonsOfWater(newGallonsOfWater : int) : void` - Sets a new value for gallons of water.
- `setCupsOfSugar(newCupsOfSugar : int) : void` - Sets a new value for cups of sugar.
- `setEmptyGlasses(newEmptyGlasses : int) : void` - Sets a new value for empty glasses.
- `setGlassesOfLemonade(newGlassesOfLemonade : int) : void` - Sets a new value for glasses of lemonade.
Transcribed Image Text:The image shows a UML (Unified Modeling Language) class diagram for a class named `LemonadeStand`. This diagram outlines the structure of the `LemonadeStand` class, including its attributes and methods. Here’s a detailed explanation: ### Attributes - `lemons : int` - Represents the number of lemons available. - `gallonsOfWater : int` - Represents the gallons of water available. - `cupsOfSugar : int` - Represents the cups of sugar available. - `emptyGlasses : int` - Represents the number of empty glasses available. - `glassesOfLemonade : int` - Represents the number of glasses of lemonade available. - `price : double` - Represents the price of a glass of lemonade. - `income : double` - Represents the total income from selling lemonade. ### Methods - `LemonadeStand()` - Default constructor for initializing a lemonade stand. - `LemonadeStand(initLemons : int, initGallonsOfWater : int, initCupsOfSugar : int, initEmptyGlasses : int, initPrice : double)` - Parameterized constructor to initialize the lemonade stand with specified amounts. - `getLemons() : int` - Returns the number of lemons. - `getGallonsOfWater() : int` - Returns the gallons of water. - `getCupsOfSugar() : int` - Returns the cups of sugar. - `getEmptyGlasses() : int` - Returns the number of empty glasses. - `getGlassesOfLemonade() : int` - Returns the number of glasses of lemonade. - `getPrice() : double` - Returns the price per glass of lemonade. - `getIncome() : double` - Returns the total income. - `setLemons(newLemons : int) : void` - Sets a new value for lemons. - `setGallonsOfWater(newGallonsOfWater : int) : void` - Sets a new value for gallons of water. - `setCupsOfSugar(newCupsOfSugar : int) : void` - Sets a new value for cups of sugar. - `setEmptyGlasses(newEmptyGlasses : int) : void` - Sets a new value for empty glasses. - `setGlassesOfLemonade(newGlassesOfLemonade : int) : void` - Sets a new value for glasses of lemonade.
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education