MCPcopy Create free account
hub / github.com/Anchals24/Low-Level-Design / main

Method main

StateDesignPattern/Main.java:8–48  ·  view source on GitHub ↗
(String args[])

Source from the content-addressed store, hash-verified

6public class Main {
7
8 public static void main(String args[]){
9
10 VendingMachine vendingMachine = new VendingMachine();
11 try {
12
13 System.out.println("|");
14 System.out.println("filling up the inventory");
15 System.out.println("|");
16
17 fillUpInventory(vendingMachine);
18 displayInventory(vendingMachine);
19
20 System.out.println("|");
21 System.out.println("clicking on InsertCoinButton");
22 System.out.println("|");
23
24 States vendingState = vendingMachine.getVendingMachineState();
25 vendingState.clickOnInsertCoinButton(vendingMachine);
26
27 vendingState = vendingMachine.getVendingMachineState();
28 vendingState.insertCoin(vendingMachine, Coin.NICKEL);
29 vendingState.insertCoin(vendingMachine, Coin.QUARTER);
30 // vendingState.insertCoin(vendingMachine, Coin.NICKEL);
31
32 System.out.println("|");
33 System.out.println("clicking on ProductSelectionButton");
34 System.out.println("|");
35 vendingState.clickOnStartProductSelectionButton(vendingMachine);
36
37 vendingState = vendingMachine.getVendingMachineState();
38 vendingState.chooseProduct(vendingMachine, 102);
39
40 displayInventory(vendingMachine);
41
42 }
43 catch (Exception e){
44 displayInventory(vendingMachine);
45 }
46
47
48 }
49
50 private static void fillUpInventory(VendingMachine vendingMachine){
51 Inventory inventory = vendingMachine.getInventory();

Callers

nothing calls this directly

Calls 7

fillUpInventoryMethod · 0.95
displayInventoryMethod · 0.95
insertCoinMethod · 0.95
chooseProductMethod · 0.95

Tested by

no test coverage detected