-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathGlennAppointment.java
More file actions
74 lines (60 loc) · 1.72 KB
/
GlennAppointment.java
File metadata and controls
74 lines (60 loc) · 1.72 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
67
68
69
70
71
72
73
74
package org.codedifferently;
public class GlennAppointment {
private String timeSlot;
private GlennPatient patient;
private boolean completed;
private boolean cancelled;
//Constructor
public GlennAppointment(String timeSlot, GlennPatient patient) {
this.timeSlot = timeSlot;
this.patient = patient;
this.completed = false;
this.cancelled = false;
}
//Getters
public GlennPatient getPatient() {
return patient;
}
public boolean isCompleted() {
return completed;
}
public boolean isCancelled() {
return cancelled;
}
//Setter
public void setTimeSlot(String timeSlot) {
if (timeSlot != null && !timeSlot.trim().isEmpty()) {
this.timeSlot = timeSlot;
} else {
System.out.println("Invalid Time");
}
}
//Method
public void complete() {
if (cancelled) {
System.out.println("Appointment was cancelled");
return;
}
if (completed) {
System.out.println("Appointment was already completed");
return;
}
completed = true;
System.out.println("Appointment was check as completed");
}
public void cancel() {
if (completed) {
System.out.println("Can't cancel completed appointment");
return;
}
if (cancelled) {
System.out.println("Appointment already canceled");
return;
}
cancelled = true;
System.out.println("Appointment already canceled");
}
public String toString() {
return timeSlot + "|" + patient.getName() + " | Completed: " + completed + " | Canceled: " + cancelled;
}
}