-
카테고리
-
세부 분야
백엔드
-
해결 여부
미해결
OrderItem
22.05.26 22:07 작성 조회수 318
1
안녕하세요.
주문상품 전체 가격을 구하는 메서드 부분에서 궁금한 점이 있습니다.
private int orderPrice; //주문당시 가격
private int count; //주문당시 수량
public int getTotalPrice() {
int price = getOrderPrice() * getCount();
return price;
}
같은 클래스안에 있는 메서드이기 때문에 private인 orderPrice와 count를 바로 쓸 수 있을 것 같은데 getter로 꺼내오는 이유가 있나요?
public int getTotalPrice() {
int price = orderPrice * count;
return price;
}
답변을 작성해보세요.
2
답변 1