Repository navigation
Expand file tree
/
Copy pathAppointment.java
More file actions
executable file
·81 lines (62 loc) · 2.35 KB
/
Copy pathAppointment.java
File metadata and controls
executable file
·81 lines (62 loc) · 2.35 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
75
76
77
78
79
80
81
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package hospitalmanagementsystem;
/**
*
* @author egehanhatipoglu
*/
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class Appointment {
private int id;
private Patient patient;
private Doctor doctor;
private String status;
private LocalDateTime start;
private LocalDateTime end;
// CRITICAL requirement: Uses the Student ID to determine the appointment length.
// This ensures the program logic is unique to this submission.
private static final int APPOINTMENT_DURATION = 15 + (230316064 % 5);
// Constructor: Initializes the appointment and automatically calculates the
// 'end' time by adding the dynamic duration to the 'start' time.
public Appointment(int id, Patient patient, Doctor doctor, LocalDateTime start) {
this.id = id;
this.patient = patient;
this.doctor = doctor;
this.start = start;
this.end = start.plusMinutes(APPOINTMENT_DURATION);
this.status = "Waiting";
}
// Getters & Setters
public int getId() { return id; }
public Patient getPatient() { return patient; }
public Doctor getDoctor() { return doctor; }
public LocalDateTime getStart() { return start; }
public LocalDateTime getEnd() { return end; }
public String getStatus() { return status; }
public void setStatus(String status) { this.status = status; }
public void setId(int id) {
this.id = id;
}
public void setPatient(Patient patient) {
this.patient = patient;
}
public void setDoctor(Doctor doctor) {
this.doctor = doctor;
}
public void setStart(LocalDateTime start) {
this.start = start;
}
public void setEnd(LocalDateTime end) {
this.end = end;
}
@Override
public String toString() {
DateTimeFormatter f = DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm");
return "Appointment #" + id + " - " + patient.getFirstName() + " " + patient.getLastName() +
" Dr. " + doctor.getFirstName() + " " + doctor.getLastName() +
" (" + start.format(f) + ") - " + status;
}
}