A student the completes this project shows that they can:
- use the Java Development Kit (jdk)
- construct Java classes
- Instantiate and use Java Objects
- use and manipulate Java base data types
Variations on the Snack Bar Project have been part of Java Education since Java was created. So, we will do one. The point is to set up vending machines where a person buys snacks from those machines.
Snack has id, name, quantity, cost, vending machine id
Snack can set name, get quantity, add quantity given quantity, buy snack given quantity, get total cost given a quantity.
Vending machine has id, name
Vending Machine set and return name
Customer has id, name, cash on hand
Customer can add cash, buy given total cash used in purchase, get and set name, get cash on hand.
- Instantiate 2 customers
- Jane with $45.25
- Bob with $33.14
- Instantiate 3 Vending Machines
- Food
- Drink
- Office
- Instantiate 5 snacks
- In Vending Machine Food
- 36 Chips at $1.75
- 36 Chocolate Bar at $1.00
- 30 Pretzel at $2.00
- In Vending Machine Drink
- 24 Soda at $2.50
- 20 Water at $2.75
- In Vending Machine Food
Processing
- Customer 1 buys 3 of snack 4. Print Customer 1 Cash on hand. Print quantity of snack 4.
- Customer 1 buys 1 of snack 3. Print Customer 1 Cash on hand. Print quantity of snack 3.
- Customer 2 buys 2 of snack 4. Print Customer 2 Cash on Hand. Print quantity of snack 4.
- Customer 1 finds $10. Print Customer 1 Cash on Hand.
- Customer 1 buys 1 of snack 2. Print Customer 1 Cash on Hand. Print quantity of snack 2.
- Snack 3 gets 12 more. Print quantity of snack 3.
- Customer 2 buys 3 of snack 3. Print Customer 2 Cash on hand. Print quantity of snack 3.