Broadly, think about what objects are involved in a vending machine:
Also, Getting the coffee will be got from the factory:
Note that prepareCoffee is private method, as users don't want to know how coffee is made.
Here is the basic class diagram for vending machine(borrowed from programsfromca):
Note that VendingMachine composes SelectionPanel, Controller, Product and so on.
References
- VendingMachine - possibly an abstract class
- DrinkMachine, SnackMachine, and classes extending VendingMachine
- VendingProduct - an abstract class?
- Drink, other classes extending VendingProduct
- Coke, other classes extending Drink
- &c, &c.
Also, Getting the coffee will be got from the factory:
public class CoffeeVendingMachine extends VendingMachine{ private Milk milk; private Sugar sugar; public Coffee getCoffee(CoffeeTypeEnum coffeeType){ prepareCoffee(coffeeType); } private void prepareCoffee(CoffeeTypeEnum coffeeType{ //internal process for coffee making } }
Note that prepareCoffee is private method, as users don't want to know how coffee is made.
Here is the basic class diagram for vending machine(borrowed from programsfromca):
Note that VendingMachine composes SelectionPanel, Controller, Product and so on.
References
0 comments:
Post a Comment