개발1 주문 개발 1 (Item - 상품 개발) 이제 핵심로직인 주문을 개발한다. 제일처음으로 한 것은 Item 엔티티에 재고 증가와 재고 감소에 대한 메서드를 만들어주는 것이다. - 재고 증가 public void addStock(int quantity){ this.stockQuantity += quantity; } - 재고 감소 public void removeStock(int quantity){ int restStock = this.stockQuantity - quantity; if(restStock < 0){ throw new NotEnoughStockException("need more stock"); } this.stockQuantity = restStock; } 재고 증가와 재고 감소는 현재 객체로 받은 재고에서 변동이 생기는 quanti.. 2022. 7. 14. 이전 1 다음