Tuesday, June 14, 2016

Design a Vending Machine

Design a Vending Machine which can accept different coins, deliver different products

http://javarevisited.blogspot.in/2016/06/design-vending-machine-in-java.html
http://javarevisited.blogspot.in/2016/06/java-object-oriented-analysis-and-design-vending-machine-part-2.html

class VendingMachine
    - boolean takeMoney(Money money);
    //Here item will contain type & quantity, no smart search required 
    //say user need half litere Coke.
    - Item pickItem(Item item); 
    - boolean isAvilable(Item item)
    - Double askForAmount(Input input);
    - Double valiDateAndReturnBalance(Money money);
class Money
    -CurrencyType type;
    -Double amount  
class MoneyValidator
    - boolean validate(Money amount);
class Item
    -ItemType type;
    -Double quantity
    -String barcode; // May be anything else to identify it
class Input
    - CommandType type;
    - Double quantity
    - ItemType type;
class display
    - void updateDisplay(String instructions)
class KeyPad
    - Input readUserInput(Key key);
class Key
    -KeyType type
    -Double value

enum CurrencyType
enum ItemType
enum KeyType
enum CommandType

http://javarevisited.blogspot.com/2012/06/20-design-pattern-and-software-design.html#ixzz4BcfqpY2j
http://ramj2ee.blogspot.in/2014/02/state-design-pattern-implementation.html#.V7NUPph95nL

No comments:

Post a Comment