-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava075_class.java
More file actions
56 lines (48 loc) · 1.25 KB
/
Copy pathJava075_class.java
File metadata and controls
56 lines (48 loc) · 1.25 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
package java0829_class;
/*
김병조/외과/39
이상만/내과/50
박상기/피부과/20
오상수/내과/25
윤달수/피부과/30
*/
/*
* [출력결과]
* 박상기 피부과 20
* 윤달수 피부과 30
*/
class Doctor {
String name; // 의사명
String medical; // 진료과목
int patient; // 대기환자수
public Doctor(String name, String medical, int patient) {
this.name = name;
this.medical = medical;
this.patient = patient;
}
public void prn() {
System.out.printf("%s %s %d\n", name, medical, patient);
}
}// end Doctor
public class Java075_class {
public static void main(String[] args) {
Doctor[] dt = new Doctor[5];
// 여기를 구현하세요//////////
dt[0] = new Doctor("김병조", "외과", 39);
dt[1] = new Doctor("이상만", "내과", 50);
dt[2] = new Doctor("박상기", "피부과", 20);
dt[3] = new Doctor("오상수", "내과", 25);
dt[4] = new Doctor("윤달수", "피부과", 30);
//////////////////////
search(dt, "피부과");
}// end main()
public static void search(Doctor[] dt, String medical) {
// 여기를 구현하세요/////////////
for (int i = 0; i < dt.length; i++) {
if (medical == dt[i].medical) {
dt[i].prn();
}
}
/////////////////////////
}
}// end class