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

Method addItem

StateDesignPattern/Inventory.java:31–43  ·  view source on GitHub ↗
(Item item, int codeNumber)

Source from the content-addressed store, hash-verified

29 }
30
31 public void addItem(Item item, int codeNumber) throws Exception {
32
33 for (ItemShelf itemShelf : itemShelves) {
34 if (itemShelf.code == codeNumber) {
35 if (itemShelf.isSoldOut()) {
36 itemShelf.item = item;
37 itemShelf.setSoldOut(false);
38 } else {
39 throw new Exception("already item is present, you can not add item here");
40 }
41 }
42 }
43 }
44
45 public Item getItem(int codeNumber) throws Exception {
46

Callers

nothing calls this directly

Calls 2

isSoldOutMethod · 0.80
setSoldOutMethod · 0.80

Tested by

no test coverage detected