-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProb04_class.java
More file actions
61 lines (49 loc) · 1.14 KB
/
Copy pathProb04_class.java
File metadata and controls
61 lines (49 loc) · 1.14 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package java0828_class.answ;
/*1 Office클래스를 이용한 객체를 생성할때 chk멤버변수에 2로 초기값을 할당하시오.
* 1이면 합격 2이면 불합격
*
* 2 출력결과
* 번호 점수 합격여부
* 1 90 1
* 2 65 2
* 3 85 1
*/
class Office {
int num;
int jumsu;
int chk;
public Office(int chk) {
this.chk = chk;
}
// 프로그램을 컴파일할때 정상적으로 수행이 되도록 생성자를 정의하시오.
public Office(int num, int jumsu) {
this.num = num;
this.jumsu = jumsu;
}
public void count() {
// 점수가 80이상이면 chk에 1로 변경한다.
if (jumsu >= 80) {
chk = 1;
} else {
chk = 2;
}
}
public void prn() {
System.out.printf("%d %d %d\n", num, jumsu, chk);
}
public void process() {
count();
prn();
}
}
public class Prob04_class {
public static void main(String[] args) {
// 문제를 풀때는 주석을 해제후 한다.
Office p1 = new Office(1, 90);
Office p2 = new Office(2, 65);
Office p3 = new Office(3, 85);
p1.process();
p2.process();
p3.process();
}// end main()
}// end class