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

Method getItem

StateDesignPattern/Inventory.java:45–58  ·  view source on GitHub ↗
(int codeNumber)

Source from the content-addressed store, hash-verified

43 }
44
45 public Item getItem(int codeNumber) throws Exception {
46
47 for (ItemShelf itemShelf : itemShelves) {
48 if (itemShelf.code == codeNumber) {
49 if (itemShelf.isSoldOut()) {
50 throw new Exception("item already sold out");
51 } else {
52
53 return itemShelf.item;
54 }
55 }
56 }
57 throw new Exception("Invalid Code");
58 }
59
60 public void updateSoldOutItem(int codeNumber){
61 for (ItemShelf itemShelf : itemShelves) {

Callers

nothing calls this directly

Calls 1

isSoldOutMethod · 0.80

Tested by

no test coverage detected