top of page

Vending Machine Low Level System Design

User Flow diagram of vending machine




Interfaces:

these interfaces contains all the possible state of the vending machine.



public interface CoinHandler {    

public void insertCoin(Coin coin);

}


public interface ItemDispenser {    

void dispenseItem(Item item, int quantity);

}


public interface ItemSelector {    

public void selectItem(Item item, int quantity);

}


public interface TransactionHandler {    

void cancel();    

void refund();

}


State class which are implementing these interfaces


NoCoinState Class: this is an idea state of vending machine, and this state only support insert coin feature.


HasCoinState Class: this is the second stage , when user enters coin then user can select item and quantity of the item.


In this stage user can cancel the process and well and get the refund



ItemSelectedState Class: this is a third stage of a vending machine, when user enters coin and selected the item then user can dispatch the item


Coin Enum: this is a simple coin enum


Item Class: here we can add the items


Inventory Class: this class is used to manage the item of a vending machine so that we can easily track the items availability



Vending Machine State: class to manage current state value of a vending machine, i.e how much balance has been inserted and what item is selected and the what are the coins



Class Vending Machine: this class have all the other classes using that we can perform all the tasks of vending machine


Main class: to test the all code


Please feel free to suggest your opinion

Happy Coding !!

Recent Posts

See All

Comments


Call 

7869617359

Email 

Follow

  • Facebook
  • Twitter
  • LinkedIn
  • Instagram
Never Miss a Post. Subscribe Now!

Thanks for submitting!

bottom of page