- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.java
More file actions
Latest commit
27 lines (21 loc) · 856 Bytes
/
Copy pathProduct.java
File metadata and controls
27 lines (21 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
packageweek02.intermediate;
publicclassProduct {
Stringname;
intprice;
Product(Stringname, intprice){
this.name = name;
this.price = price;
}
publicStringgetName() {
returnname;
}
publicintgetPrice() {
returnprice;
}
// 15단계(응용): 특정 조건의 객체만 골라내기
// 문제: Product.java에 상품명(name)과 가격(price) 멤버 변수를 만드세요.ProductTest.java에서
// Product 객체 배열에 여러 상품 정보를 저장하세요. for문과 if문을 사용하여 가격이 10000원 이상인 상품의
// 이름만 출력하세요.
// 핵심 사고: 객체 배열을 순회하며 각 객체의 상태(멤버 변수)에 따라 조건부 로직을 처리하는 능력을 기릅니다.
// 힌트: 객체 배열, 클래스, for문, if문, getter, 비교 연산자
}