200 likes | 219 Views
Vending Machine Modeling. 2003 Fall Software Design (CSED332) Oct. 30 th , 2003. Agenda. Domain Model Use Case Collaboration Diagram Design Class Diagram Message Sequence Diagram. ItemManagement. TransactionManagement. SelectionButton. total. quantity. ItemLight. ItemDispenser.
E N D
Vending Machine Modeling 2003 Fall Software Design (CSED332) Oct. 30th, 2003
Agenda • Domain Model • Use Case • Collaboration Diagram • Design Class Diagram • Message Sequence Diagram
ItemManagement TransactionManagement SelectionButton total quantity ItemLight ItemDispenser Owner Customer ReturnButton ItemSpec price MoneyCounter MoneyDispenser c50_Count c100_Count c500_Count bill_Count CoinReceiver BillReceiver MoneyDisplay Vending Machine Domain Model Domain Model modify 1 1..* 1 1 1 describes-item request- dispense add or remove item 1 1 1 1..* push notify- selection turn-on or -off 1..* 1 1 1 1 add or remove money 1..* Inform-deduction Inform-total 1 push 1 1 display-total-of 1 notify- change- request 1 1 * * 1 request- change- dispense add-money query-if-changeable 1 * * 1 Insert coin deposit-money-to 1 1 1 Request- dispense deposit-money-to Insert bill 1 1 1 1 1
Vending Machine Use Cases (1) Use Case • Actors and their goal • Owner • to fill items • to fill money • to change item (info.) • Customer • - to buy one or more drinks • Corresponding Use Cases • Fill Items • Fill Money • Change Items • Customer • - Buy Items
Vending Machine Use Cases (2) Use Case • Use Case: Buy Items • Primary Actor: Customer • Stakeholders: • Tax Collector - interested in collecting correct sales tax • Precondition: Vending Machine (VM) turned on, not in manager mode, • and the numbers of each item contained in VM • greater than zero. • Post-condition: Customer gets one or more items and exact change. • Main Success Scenario • *1. Customer deposits money. • *2. Customer selects an item. • *3. Customer gets change. • At any time, 1~3 can be repeated in arbitrary order.
Vending Machine Use Cases (3) Use Case • Use Case: Deposit Money • Primary Actor: Customer • Precondition: Vending machine turned on, not in manager mode • Post-condition: Total amount of money updated • and item lights for selectable items are turned on. • Main Success Scenario • 1. Customer inserts a coin or bill. • 2. Vending Machine (VM) updates display with the total amount • deposited. • 3. VM turns on item lights for selectable items. • Extensions • 1a. If an irregular coin or bill is inserted, the VM rejects it.
Vending Machine Use Cases (4) Use Case • Use Case: Select an Item • Primary Actor: Customer • Precondition: Vending machine turned on, not in manager mode, • and selectable items lighted • Post-condition: Customer gets a selected item if s/he choose • selectable one and the total amount of money is • deducted by the price of the dispensed item. • Main Success Scenario • 1. Customer pushes a selection button. • 2. If the item corresponds to the pushed button is selectable, • VM dispenses the item and deduct total amount of money by • the price of the item. • 3. VM turns on item lights for selectable items • and turns off item lights for not selectable items.
Vending Machine Use Cases (5) Use Case • Use Case: Get Change • Primary Actor: Customer • Precondition: Vending machine turned on, not in manager mode • Post-condition: User gets exact change. • Total amount of money is updated to zero. • Main Success Scenario • 1. Customer push the button to get the change. • 2. VM updates money display to zero. • 3. VM turns off all item lights. • 4. VM returns change.
Vending Machine Use Cases (6) Use Case • Use Case: Fill Items • Primary Actor: Owner • Precondition: Vending machine turned on, not in use by the user • Post-condition: Item refilled and item number updated • Main Success Scenario • 1. Owner opens the cover. • 2. Owner fills items. • 3. VM counts and updates item numbers. • 4. Owner closes the cover.
Vending Machine Use Cases (7) Use Case • Use Case: Fill Money • Primary Actor: Owner • Precondition: Vending machine turned on and not in use by the user • Post-condition: Money refilled and the amount is updated • Main Success Scenario • 1. Owner opens the cover. • 2. Owner fills coins and bills into money holders. • 3. VM counts and updates money amount. • 4. Owner closes the cover.
Vending Machine Use Cases (8) Use Case • Use Case: Change Items • Primary Actor: Owner • Precondition: Vending machine turned on, not in use by the user • Post-condition: Item price information changed • Main Success Scenario • 1. Owner opens the cover. • 2. Owner sets new price for items. • 3. Owner closes the cover.
Vending Machine SSD (1) System Sequence Diagram :Customer :System SSD1 – deposit money inserts money( coin or bill ) Money display is updated. Item lights for selectable items are turned on. :Customer :System SSD2 – select an item selects an item selected item dispensed Money display is updated. Item lights for selectable items are turned on. :Customer :System SSD3 – get change request change Money display is reset to zero. All item lights are turned off. change returned
Vending Machine SSD (2) System Sequence Diagram :Owner :System SSD4 – fill items open cover fill items close cover :Owner :System SSD5 – fill money open cover fill money close cover :Owner :System SSD6 – change items open cover modify item price close cover
getPrice() setPrice( price ) ItemManagement TransactionManagement total: Integer quantity: Integer SelectionButton totalChanged( total ) setQuantity( num ) processSelection() ItemLight MoneyDispenser ItemDispenser turnOn() turnOff() ReturnButton dispense( count ) dispense() ItemSpec price: Integer PriceInputDevice ItemRefillSensor MoneyRefillSensor addMoney( amount) deduct( amount ) getTotal() returnChange() CoinReceiver BillReceiver MoneyCounter c50_Count: Integer c100_Count: Integer c500_Count: Integer bill_Count: Integer isChangeable( amount ): Boolean deposit( amount ) setMoney( type, count ) returnChange( amount ) Design Class Diagram of VM Design Class Diagram setPrice 1 1..* 1 getPrice 1 1 1 dispense processSelection 1 1 turn-on turn-off 1 1 setQuantity 1 1 1..* totalChanged deduct, getTotal 1 isChangeable MoneyDisplay 1 returnChange display 1 1 1 display(num) 1 returnChange addMoney 1 deposit 1 1 deposit dispense 1 1 1 1..* setMoney 1..* 1
Message Sequence Diagram Deposit Money
Message Sequence Diagram Select an Item
Message Sequence Diagram Get Change
Message Sequence Diagram Others MSD for Fill Items MSD for Fill Money MSD for Change Items
References • Craig Larman, Applying UML and Patterns 2nd Ed., 2001, PHPTR