-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoctor.java
More file actions
66 lines (58 loc) · 1.9 KB
/
Copy pathDoctor.java
File metadata and controls
66 lines (58 loc) · 1.9 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
62
63
64
65
66
public class Doctor {
private String doctorId;
private String name;
private String specialization;
private int patientsTreated;
public Doctor(String doctorId, String name, String specialization){
if(name.isEmpty()){
throw new IllegalArgumentException("Name cannot be null or empty");
}
if(specialization.isEmpty()){
throw new IllegalArgumentException("Specialization cannot be null or empty");
}
this.doctorId = doctorId;
this.name = name;
this.specialization = specialization;
}
public String getDoctorId(){
return doctorId;
}
public void setDoctorId(String doctorId){
this.doctorId = doctorId;
}
public String getName(){
return name;
}
public void setName(String name){
if(name.isEmpty()){
throw new IllegalArgumentException("Name cannot be null or empty");
}
this.name = name;
}
public String getSpecialization(){
return specialization;
}
public void setSpecialization(String specialization){
if(specialization.isEmpty()){
throw new IllegalArgumentException("Specialization cannot be null or empty");
}
this.specialization = specialization;
}
public int getPatientsTreated(){
return patientsTreated;
}
public void setPatientsTreated(int patientsTreated){
this.patientsTreated = patientsTreated;
}
public void treatPatient(){
patientsTreated++;
System.out.println("Patient treated successfully. Total patients treated " + patientsTreated);
}
@Override
public String toString(){
return
"doctorId : " + doctorId + '\n' +
"name : " + name + '\n' +
"specialization : " + specialization + '\n';
}
}