From 21b829524f1d9423efb9a86d8651bcfa2fa9c4cf Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Thu, 19 Feb 2026 16:58:28 -0500 Subject: [PATCH 01/13] Done classes --- src/main/java/org/codedifferently/GlennAppointment.java | 4 ++++ .../org/codedifferently/{Main.java => GlennClinicApp.java} | 2 +- src/main/java/org/codedifferently/GlennClinicSystem.java | 4 ++++ src/main/java/org/codedifferently/GlennPatient.java | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/codedifferently/GlennAppointment.java rename src/main/java/org/codedifferently/{Main.java => GlennClinicApp.java} (96%) create mode 100644 src/main/java/org/codedifferently/GlennClinicSystem.java create mode 100644 src/main/java/org/codedifferently/GlennPatient.java diff --git a/src/main/java/org/codedifferently/GlennAppointment.java b/src/main/java/org/codedifferently/GlennAppointment.java new file mode 100644 index 0000000..c4d0877 --- /dev/null +++ b/src/main/java/org/codedifferently/GlennAppointment.java @@ -0,0 +1,4 @@ +package org.codedifferently; + +public class GlennAppointment { +} diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/GlennClinicApp.java similarity index 96% rename from src/main/java/org/codedifferently/Main.java rename to src/main/java/org/codedifferently/GlennClinicApp.java index 435139b..06162c1 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/GlennClinicApp.java @@ -2,7 +2,7 @@ //TIP To Run code, press or // click the icon in the gutter. -public class Main { +public class GlennClinicApp{ public static void main(String[] args) { //TIP Press with your caret at the highlighted text // to see how IntelliJ IDEA suggests fixing it. diff --git a/src/main/java/org/codedifferently/GlennClinicSystem.java b/src/main/java/org/codedifferently/GlennClinicSystem.java new file mode 100644 index 0000000..161306f --- /dev/null +++ b/src/main/java/org/codedifferently/GlennClinicSystem.java @@ -0,0 +1,4 @@ +package org.codedifferently; + +public class GlennClinicSystem { +} diff --git a/src/main/java/org/codedifferently/GlennPatient.java b/src/main/java/org/codedifferently/GlennPatient.java new file mode 100644 index 0000000..6ea4394 --- /dev/null +++ b/src/main/java/org/codedifferently/GlennPatient.java @@ -0,0 +1,4 @@ +package org.codedifferently; + +public class GlennPatient { +} From 3d655bc5a6045c66e9c9ed70af104091b08e4424 Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Thu, 19 Feb 2026 22:06:15 -0500 Subject: [PATCH 02/13] started clinic app/System --- .../org/codedifferently/GlennClinicApp.java | 201 ++++++++++++++++-- .../codedifferently/GlennClinicSystem.java | 35 +++ 2 files changed, 224 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/codedifferently/GlennClinicApp.java b/src/main/java/org/codedifferently/GlennClinicApp.java index 06162c1..ae8fbeb 100644 --- a/src/main/java/org/codedifferently/GlennClinicApp.java +++ b/src/main/java/org/codedifferently/GlennClinicApp.java @@ -1,17 +1,194 @@ package org.codedifferently; -//TIP To Run code, press or -// click the icon in the gutter. + +import java.util.ArrayList; +import java.util.Scanner; + public class GlennClinicApp{ public static void main(String[] args) { - //TIP Press with your caret at the highlighted text - // to see how IntelliJ IDEA suggests fixing it. - System.out.printf("Hello and welcome!"); - - for (int i = 1; i <= 5; i++) { - //TIP Press to start debugging your code. We have set one breakpoint - // for you, but you can always add more by pressing . - System.out.println("i = " + i); - } + + + theClinic(); + + } + /* + Quick cheat sheet: where methods belong +ClinicApp (controller) +display menu +get user input +call system methods +loop until exit + +ClinicSystem (logic + storage) +add/search/check-in patient +schedule/cancel appointments +prevent double booking +daily report calculations + +Patient (individual record) +checkIn() +getters/setters +toString()/display() + +Appointment (individual record) +cancel()/complete() +getters/setters +toString()/display() + */ + + public static void theClinic() { + Scanner scan = new Scanner(System.in); + GlennClinicSystem system = new GlennClinicSystem(); + + System.out.println("Welcome to Derwin Bell's Community Clinic System"); + System.out.println(""" + 1. Add New Patient + 2. View All Patients + 3. Check In Patient + 4. Search for Patient + 5. Schedule Appointment + 6. Cancel Appointment + 7. View Daily Schedule + 8. Daily Report + 9. Exit"""); + int choice = scan.nextInt(); +do { + switch (choice) { + case 1: + System.out.println("Enter Patient Name: "); + String patientName = scan.next(); + System.out.println("Enter Phone Number: "); + String phoneNumber = scan.next(); + system.addPatient(patientName, phoneNumber); + break; + + case 2: + System.out.println("PATIENT LIST"); + system.patientList(); + break; + case 3: + system.checkIn(); + break; + case 4: + system.searchPatient(); + break; + case 5: + system.schedulePatient(); + break; + case 6: + system.cancelAppointment(); + break; + case 7: + system.dailySchedule(); + break; + case 8: + system.dailyReport(); + break; + case 9: + System.exit(0); + break; + default: + System.out.println("Invalid Option"); + break; + + + } +}while(true); + + + + + } -} \ No newline at end of file +} + +/* Example output +Welcome to Derwin Bell's Community Clinic System + +1. Add New Patient +2. View All Patients +3. Check In Patient +4. Search for Patient +5. Schedule Appointment +6. Cancel Appointment +7. View Daily Schedule +8. Daily Report +9. Exit + +Enter your choice: 1 + +Enter Patient Name: John Smith +Enter Phone Number: 555-1234 + +Patient added successfully! +Patient ID: 101 + +Enter your choice: 2 + +Patient List: +ID: 101 | Name: John Smith | Checked In: No +ID: 102 | Name: Sarah Johnson | Checked In: No + +Enter your choice: 3 + +Enter Patient ID to Check In: 101 + +Patient John Smith checked in successfully. + +Enter your choice: 4 + +Enter Patient ID to search: 102 + +Patient Found! +------------------------- +Patient ID: 102 +Name: Sarah Johnson +Phone Number: 555-7890 +Checked In: Yes +Appointment Time: 11:00 AM + +Enter your choice: 5 + +Available Time Slots: +1. 9:00 AM +2. 10:00 AM +3. 11:00 AM +4. 1:00 PM +5. 2:00 PM + +Select a time slot: 2 +Enter Patient ID: 101 + +Appointment scheduled at 10:00 AM. + +Enter your choice: 6 + +Enter Patient ID to cancel appointment: 102 + +Appointment for Sarah Johnson at 11:00 AM has been cancelled successfully. + +Enter your choice: 7 + +Daily Schedule: +9:00 AM - Available +10:00 AM - John Smith +11:00 AM - Available +1:00 PM - Available +2:00 PM - Available + +Enter your choice: 8 + +Daily Summary Report +------------------------- +Total Patients Checked In: 1 +Appointments Scheduled: 1 +Appointments Completed: 0 +Waitlisted Patients: 0 + +Enter your choice: 9 + +Thank you for using the Community Clinic System. +Goodbye! + + + */ \ No newline at end of file diff --git a/src/main/java/org/codedifferently/GlennClinicSystem.java b/src/main/java/org/codedifferently/GlennClinicSystem.java index 161306f..ed0cab9 100644 --- a/src/main/java/org/codedifferently/GlennClinicSystem.java +++ b/src/main/java/org/codedifferently/GlennClinicSystem.java @@ -1,4 +1,39 @@ package org.codedifferently; + + public class GlennClinicSystem { + + public void patientList(){ + + } + + public void addPatient(String name, String phoneNumber){ + + } + + public void checkIn(){ + + } + + public void searchPatient(){ + + } + + public void schedulePatient(){ + + } + + public void cancelAppointment(){ + + } + + public void dailySchedule(){ + + } + + public void dailyReport(){ + + } + } From 40108cbb71326416a714bb8ced153889635069d2 Mon Sep 17 00:00:00 2001 From: glenntyson Date: Thu, 19 Feb 2026 22:15:25 -0500 Subject: [PATCH 03/13] Added setter and getters to the GlennPatitent class --- .idea/copilot.data.migration.ask2agent.xml | 6 ++++ .idea/misc.xml | 1 - .../org/codedifferently/GlennPatient.java | 28 +++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .idea/copilot.data.migration.ask2agent.xml diff --git a/.idea/copilot.data.migration.ask2agent.xml b/.idea/copilot.data.migration.ask2agent.xml new file mode 100644 index 0000000..1f2ea11 --- /dev/null +++ b/.idea/copilot.data.migration.ask2agent.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index fdc35ea..17e9c2e 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/src/main/java/org/codedifferently/GlennPatient.java b/src/main/java/org/codedifferently/GlennPatient.java index 6ea4394..81e5593 100644 --- a/src/main/java/org/codedifferently/GlennPatient.java +++ b/src/main/java/org/codedifferently/GlennPatient.java @@ -1,4 +1,32 @@ package org.codedifferently; public class GlennPatient { + private int idCounter = 1; + private int id; + private String name; + private boolean checkedIn; + + public void glennPatient(String name) { + this.id = idCounter++; + this.name = name; + this.checkedIn = false; + + } + + public int getId() { + return id; + } + public String getName(){ + return name; + } + public boolean isCheckedIn(){ + return checkedIn; + } + public void checkIn(){ + this.checkedIn =true; + } + public String toString(){ + return "ID: " +id +" | Name: " +name+"| Checked In: " + checkedIn; + } + } From ea87b9c1a6c2ecf42bf2b89d50ac04999ee02ac8 Mon Sep 17 00:00:00 2001 From: glenntyson Date: Fri, 20 Feb 2026 08:10:34 -0500 Subject: [PATCH 04/13] Added appointment class and refined patient class to have prio patients --- .../org/codedifferently/GlennAppointment.java | 29 ++++++++++++++++++ .../org/codedifferently/GlennPatient.java | 30 ++++++++++++++----- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/codedifferently/GlennAppointment.java b/src/main/java/org/codedifferently/GlennAppointment.java index c4d0877..b4d8a90 100644 --- a/src/main/java/org/codedifferently/GlennAppointment.java +++ b/src/main/java/org/codedifferently/GlennAppointment.java @@ -1,4 +1,33 @@ package org.codedifferently; public class GlennAppointment { + private String timeSlot; + private GlennPatient patient; + private boolean completed; + + public void glennAppointment(String timeSlot, GlennPatient patient) + { + this.timeSlot=timeSlot; + this.patient=patient; + this.completed=false; + } + +public String getTimeSlot(){ + return timeSlot; +} +public GlennPatient getPatient(){ + return patient; +} +public boolean isCompleted(){ + return completed; +} +public void markCompleted(){ + completed=true; +} + +public String toString(){ + return timeSlot + "|" + patient.getName() + " | Priority: " +patient.getPriority() +" | Completed: " +completed; +} + + } diff --git a/src/main/java/org/codedifferently/GlennPatient.java b/src/main/java/org/codedifferently/GlennPatient.java index 81e5593..f7c8a15 100644 --- a/src/main/java/org/codedifferently/GlennPatient.java +++ b/src/main/java/org/codedifferently/GlennPatient.java @@ -1,14 +1,20 @@ package org.codedifferently; +import java.util.concurrent.atomic.AtomicInteger; + public class GlennPatient { - private int idCounter = 1; + private static AtomicInteger idCounter = new AtomicInteger(1000); private int id; + private int age; private String name; private boolean checkedIn; + private String priority; // Emergency , Reg, Follow public void glennPatient(String name) { - this.id = idCounter++; + this.id = idCounter.getAndIncrement(); this.name = name; + this.age = age; + this.priority = priority; this.checkedIn = false; } @@ -16,17 +22,25 @@ public void glennPatient(String name) { public int getId() { return id; } - public String getName(){ + + public String getName() { return name; } - public boolean isCheckedIn(){ + + public boolean isCheckedIn() { return checkedIn; } - public void checkIn(){ - this.checkedIn =true; + + public void checkIn() { + this.checkedIn = true; } - public String toString(){ - return "ID: " +id +" | Name: " +name+"| Checked In: " + checkedIn; + + public String getPriority() { + return priority; + } + + public String toString() { + return "ID: " + id + " | Name: " + name + "Age: " + age + " | Priority: " + priority + "| Checked In: " + checkedIn; } } From 5c3cbd5ba05dd586b01bc5f3766db4a06ad59ae7 Mon Sep 17 00:00:00 2001 From: glenntyson Date: Fri, 20 Feb 2026 08:39:08 -0500 Subject: [PATCH 05/13] Refinded the two methods with setter and added cancel --- .../org/codedifferently/GlennAppointment.java | 98 +++++++++++++++---- .../org/codedifferently/GlennPatient.java | 25 ++++- 2 files changed, 102 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/codedifferently/GlennAppointment.java b/src/main/java/org/codedifferently/GlennAppointment.java index b4d8a90..82af3c0 100644 --- a/src/main/java/org/codedifferently/GlennAppointment.java +++ b/src/main/java/org/codedifferently/GlennAppointment.java @@ -2,32 +2,94 @@ public class GlennAppointment { private String timeSlot; - private GlennPatient patient; + private GlennPatient patient; private boolean completed; + private boolean cancelled; - public void glennAppointment(String timeSlot, GlennPatient patient) - { - this.timeSlot=timeSlot; - this.patient=patient; - this.completed=false; + public void glennAppointment(String timeSlot, GlennPatient patient) { + this.timeSlot = timeSlot; + this.patient = patient; + this.completed = false; + this.cancelled = false; } -public String getTimeSlot(){ + public String getTimeSlot() { return timeSlot; -} -public GlennPatient getPatient(){ + } + + public GlennPatient getPatient() { return patient; -} -public boolean isCompleted(){ + } + + public boolean isCompleted() { return completed; -} -public void markCompleted(){ - completed=true; -} + } -public String toString(){ - return timeSlot + "|" + patient.getName() + " | Priority: " +patient.getPriority() +" | Completed: " +completed; -} + public boolean isCancelled() { + return cancelled; + } + + public void setPatient(GlennPatient patient) { + if (patient != null) { + this.patient = patient; + } else { + System.out.println("Invalid patient"); + } + } + + public void setTimeSlot(String timeSlot) { + if (timeSlot != null && !timeSlot.trim().isEmpty()) { + this.timeSlot = timeSlot; + } else { + System.out.println("Invalid Time"); + } + } + + public void setCompleted(boolean completed) { + if (!cancelled) { + this.completed = completed; + } else { + System.out.println("Appointment was cancelled"); + } + } + + public void setCancelled(boolean cancelled) { + if (!completed) { + this.cancelled = cancelled; + } else { + System.out.println("Appointment was completed"); + } + } + + 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() + " | Priority: " + patient.getPriority() + " | Completed: " + completed + " | Canceled: " + cancelled; + } } diff --git a/src/main/java/org/codedifferently/GlennPatient.java b/src/main/java/org/codedifferently/GlennPatient.java index f7c8a15..589c051 100644 --- a/src/main/java/org/codedifferently/GlennPatient.java +++ b/src/main/java/org/codedifferently/GlennPatient.java @@ -23,6 +23,7 @@ public int getId() { return id; } + public String getName() { return name; } @@ -31,13 +32,31 @@ public boolean isCheckedIn() { return checkedIn; } + public String getPriority() { + return priority; + } + + public int setId(int id) { + if (id > 0) { + this.id = id; + } else { + System.out.println("Invalid ID."); + } + return id; + } + + public void setName(String name) { + if (name != null && !name.trim().isEmpty()) { + this.name = name; + } else { + System.out.println("Invalid Name."); + } + } + public void checkIn() { this.checkedIn = true; } - public String getPriority() { - return priority; - } public String toString() { return "ID: " + id + " | Name: " + name + "Age: " + age + " | Priority: " + priority + "| Checked In: " + checkedIn; From 591d29d2715eaf71f8874b2477f66d2be7d9b35b Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Fri, 20 Feb 2026 14:00:05 -0500 Subject: [PATCH 06/13] option 1-3 done --- .../org/codedifferently/GlennAppointment.java | 4 +- .../org/codedifferently/GlennClinicApp.java | 23 ++++---- .../codedifferently/GlennClinicSystem.java | 57 ++++++++++++++++++- .../org/codedifferently/GlennPatient.java | 14 ++--- 4 files changed, 77 insertions(+), 21 deletions(-) diff --git a/src/main/java/org/codedifferently/GlennAppointment.java b/src/main/java/org/codedifferently/GlennAppointment.java index 82af3c0..dab3182 100644 --- a/src/main/java/org/codedifferently/GlennAppointment.java +++ b/src/main/java/org/codedifferently/GlennAppointment.java @@ -6,7 +6,7 @@ public class GlennAppointment { private boolean completed; private boolean cancelled; - public void glennAppointment(String timeSlot, GlennPatient patient) { + public GlennAppointment(String timeSlot, GlennPatient patient) { this.timeSlot = timeSlot; this.patient = patient; this.completed = false; @@ -88,7 +88,7 @@ public void cancel() { } public String toString() { - return timeSlot + "|" + patient.getName() + " | Priority: " + patient.getPriority() + " | Completed: " + completed + " | Canceled: " + cancelled; + return timeSlot + "|" + patient.getName() + " | Completed: " + completed + " | Canceled: " + cancelled; } diff --git a/src/main/java/org/codedifferently/GlennClinicApp.java b/src/main/java/org/codedifferently/GlennClinicApp.java index ae8fbeb..e26ad42 100644 --- a/src/main/java/org/codedifferently/GlennClinicApp.java +++ b/src/main/java/org/codedifferently/GlennClinicApp.java @@ -1,7 +1,7 @@ package org.codedifferently; -import java.util.ArrayList; + import java.util.Scanner; public class GlennClinicApp{ @@ -40,8 +40,10 @@ public static void theClinic() { Scanner scan = new Scanner(System.in); GlennClinicSystem system = new GlennClinicSystem(); - System.out.println("Welcome to Derwin Bell's Community Clinic System"); - System.out.println(""" + +do { + System.out.println("Welcome to Derwin Bell's Community Clinic System"); + System.out.println(""" 1. Add New Patient 2. View All Patients 3. Check In Patient @@ -51,15 +53,14 @@ public static void theClinic() { 7. View Daily Schedule 8. Daily Report 9. Exit"""); - int choice = scan.nextInt(); -do { + int choice = scan.nextInt(); + switch (choice) { case 1: System.out.println("Enter Patient Name: "); String patientName = scan.next(); - System.out.println("Enter Phone Number: "); - String phoneNumber = scan.next(); - system.addPatient(patientName, phoneNumber); + + system.addPatient(patientName); break; case 2: @@ -67,7 +68,8 @@ public static void theClinic() { system.patientList(); break; case 3: - system.checkIn(); + system.checkPatientIn(); + break; case 4: system.searchPatient(); @@ -76,6 +78,7 @@ public static void theClinic() { system.schedulePatient(); break; case 6: + system.cancelAppointment(); break; case 7: @@ -165,7 +168,7 @@ public static void theClinic() { Enter Patient ID to cancel appointment: 102 -Appointment for Sarah Johnson at 11:00 AM has been cancelled successfully. +Appointment for Sarah Johnson at 11:00 AM has been canceled successfully. Enter your choice: 7 diff --git a/src/main/java/org/codedifferently/GlennClinicSystem.java b/src/main/java/org/codedifferently/GlennClinicSystem.java index ed0cab9..9c208bc 100644 --- a/src/main/java/org/codedifferently/GlennClinicSystem.java +++ b/src/main/java/org/codedifferently/GlennClinicSystem.java @@ -1,22 +1,73 @@ package org.codedifferently; +import java.util.ArrayList; +import java.util.Scanner; public class GlennClinicSystem { + public ArrayList patients = new ArrayList<>(); + public ArrayList id = new ArrayList<>(); + public ArrayList checked = new ArrayList<>(); + public void patientList(){ + GlennPatient gP = new GlennPatient(); + for(int i =0; i < patients.size(); i++){ + System.out.println("ID:" + id.get(i) + "| Name: " + patients.get(i) + "| Checked In: " + gP.isCheckedIn()); + + } } - public void addPatient(String name, String phoneNumber){ + public void addPatient(String name){ + GlennPatient gP = new GlennPatient(); + + + gP.setName(name); + patients.add(gP.getName()); + gP.setId(gP.getId()); + id.add(gP.getId()); + System.out.println("Patient added successfully!"); + System.out.println("Patient ID: " + gP.getId()); + } - public void checkIn(){ + public void checkPatientIn(){ + + GlennPatient glennPatient = new GlennPatient(); + Scanner scan = new Scanner(System.in); + System.out.println("Enter Patient ID to check"); + int patientId = scan.nextInt(); + + for (int i=0; i < id.size(); i++) { + if(id.get(i) == patientId){ + + System.out.println("Patient " + patients.get(i) + " checked in successfully."); + } + } + + glennPatient.checkIn(); } + public void searchPatient(){ + GlennPatient glennPatient = new GlennPatient(); + Scanner scan = new Scanner(System.in); + System.out.println("Patient ID: "); + int pId = scan.nextInt(); + + for (int i=0; i < id.size(); i++){ + if(pId == id.get(i)){ + System.out.println("Patient ID:" + id.get(i) + "\n" + + "Name:" + patients.get(i) + "\n" + + "Checked In: " + glennPatient.isCheckedIn() + "\n" + + "Appointment Time: " + "\n"); + } + + } + } @@ -24,10 +75,12 @@ public void schedulePatient(){ } + public void cancelAppointment(){ } + public void dailySchedule(){ } diff --git a/src/main/java/org/codedifferently/GlennPatient.java b/src/main/java/org/codedifferently/GlennPatient.java index 589c051..5f10405 100644 --- a/src/main/java/org/codedifferently/GlennPatient.java +++ b/src/main/java/org/codedifferently/GlennPatient.java @@ -5,16 +5,14 @@ public class GlennPatient { private static AtomicInteger idCounter = new AtomicInteger(1000); private int id; - private int age; private String name; private boolean checkedIn; - private String priority; // Emergency , Reg, Follow + //private String priority; // Emergency , Reg, Follow - public void glennPatient(String name) { + public GlennPatient() { this.id = idCounter.getAndIncrement(); this.name = name; - this.age = age; - this.priority = priority; + this.checkedIn = false; } @@ -32,10 +30,12 @@ public boolean isCheckedIn() { return checkedIn; } - public String getPriority() { + /* public String getPriority() { return priority; } + */ + public int setId(int id) { if (id > 0) { this.id = id; @@ -59,7 +59,7 @@ public void checkIn() { public String toString() { - return "ID: " + id + " | Name: " + name + "Age: " + age + " | Priority: " + priority + "| Checked In: " + checkedIn; + return "ID: " + id + " | Name: " + name + " | " + "| Checked In: " + checkedIn; } } From b9eb6871495f21d84d9fbf59991d84e207a11ca2 Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Fri, 20 Feb 2026 23:22:54 -0500 Subject: [PATCH 07/13] option 1-5 re done --- .../codedifferently/GlennClinicSystem.java | 140 ++++++++++++++---- .../org/codedifferently/GlennPatient.java | 7 +- 2 files changed, 113 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/codedifferently/GlennClinicSystem.java b/src/main/java/org/codedifferently/GlennClinicSystem.java index 9c208bc..a1d9d59 100644 --- a/src/main/java/org/codedifferently/GlennClinicSystem.java +++ b/src/main/java/org/codedifferently/GlennClinicSystem.java @@ -6,73 +6,144 @@ public class GlennClinicSystem { - public ArrayList patients = new ArrayList<>(); - public ArrayList id = new ArrayList<>(); - public ArrayList checked = new ArrayList<>(); + private final ArrayList patients = new ArrayList<>(); + private final ArrayList appointments = new ArrayList<>(); + + private final String[] timeSlots = {"9:00 AM", "10:00 AM", "11:00 AM", "1:00 PM", "2:00 PM"}; + private final GlennAppointment[] schedule = new GlennAppointment[timeSlots.length]; + + // Use ONE scanner for the system + private final Scanner scan = new Scanner(System.in); + public void patientList(){ - GlennPatient gP = new GlennPatient(); - for(int i =0; i < patients.size(); i++){ - System.out.println("ID:" + id.get(i) + "| Name: " + patients.get(i) + "| Checked In: " + gP.isCheckedIn()); + if (patients.isEmpty()) { + System.out.println("No patients found."); + return; + } + + + for (GlennPatient p : patients) { + System.out.println("ID: " + p.getId() + + " | Name: " + p.getName() + + " | Checked In: " + p.isCheckedIn()); } } public void addPatient(String name){ - GlennPatient gP = new GlennPatient(); - gP.setName(name); - patients.add(gP.getName()); - gP.setId(gP.getId()); - id.add(gP.getId()); + GlennPatient p = new GlennPatient(); + p.setName(name); + + patients.add(p); + System.out.println("Patient added successfully!"); - System.out.println("Patient ID: " + gP.getId()); + System.out.println("Patient ID: " + p.getId()); } public void checkPatientIn(){ - GlennPatient glennPatient = new GlennPatient(); - Scanner scan = new Scanner(System.in); System.out.println("Enter Patient ID to check"); int patientId = scan.nextInt(); - for (int i=0; i < id.size(); i++) { - if(id.get(i) == patientId){ + scan.nextLine(); // consume leftover newline + + boolean found = false; - System.out.println("Patient " + patients.get(i) + " checked in successfully."); + for (GlennPatient p : patients) { + if (p.getId() == patientId) { + p.checkIn(); // ✅ THIS is what actually changes checkedIn to true + System.out.println("Patient " + p.getName() + " checked in successfully."); + found = true; + break; // stop looping once we found them } } - glennPatient.checkIn(); + if (!found) { + System.out.println("No patient found with ID: " + patientId); + } + + + } - } public void searchPatient(){ - GlennPatient glennPatient = new GlennPatient(); - Scanner scan = new Scanner(System.in); - System.out.println("Patient ID: "); - int pId = scan.nextInt(); - - for (int i=0; i < id.size(); i++){ - if(pId == id.get(i)){ - System.out.println("Patient ID:" + id.get(i) + "\n" + - "Name:" + patients.get(i) + "\n" + - "Checked In: " + glennPatient.isCheckedIn() + "\n" + - "Appointment Time: " + "\n"); - } + if (patients.isEmpty()) { + System.out.println("No patients exist yet. Add a patient first."); + } + System.out.print("Enter Patient ID to check in: "); + int patientId = scan.nextInt(); + for (GlennPatient p : patients){ + + if(p.getId() == patientId){ + p.checkIn(); + System.out.println("Patient " + p.getName() + " checked in successfully."); + + } + } } public void schedulePatient(){ + if (patients.isEmpty()) { + System.out.println("No patients exist yet. Add a patient first."); + return; + } + + System.out.println("Available Time Slots:"); + for (int i = 0; i < timeSlots.length; i++) { + String status = (schedule[i] == null) ? "Available" : "Booked"; + System.out.println((i + 1) + ". " + timeSlots[i] + " - " + status); + } + + System.out.print("Select a time slot (1-" + timeSlots.length + "): "); + int slotChoice = scan.nextInt(); + + if (slotChoice < 1 || slotChoice > timeSlots.length) { + System.out.println("Invalid time slot."); + return; + } + + int slotIndex = slotChoice - 1; + + if (schedule[slotIndex] != null) { + System.out.println("That time slot is already booked. Please choose another."); + return; + } + + System.out.print("Enter Patient ID: "); + int patientId = scan.nextInt(); + + GlennPatient p = findPatientById(patientId); + + if (p == null) { + System.out.println("Patient not found."); + return; + } + + if (!p.isCheckedIn()) { + System.out.println("Patient is not checked in yet. Please check them in first."); + return; + } + + GlennAppointment appt = new GlennAppointment(timeSlots[slotIndex], p); + + schedule[slotIndex] = appt; + appointments.add(appt); + + System.out.println("Appointment scheduled at " + + timeSlots[slotIndex] + " for " + p.getName() + "."); + } @@ -89,4 +160,11 @@ public void dailyReport(){ } + private GlennPatient findPatientById(int id) { + for (GlennPatient p : patients) { + if (p.getId() == id) return p; + } + return null; + } + } diff --git a/src/main/java/org/codedifferently/GlennPatient.java b/src/main/java/org/codedifferently/GlennPatient.java index 5f10405..a3d4f90 100644 --- a/src/main/java/org/codedifferently/GlennPatient.java +++ b/src/main/java/org/codedifferently/GlennPatient.java @@ -11,8 +11,6 @@ public class GlennPatient { public GlennPatient() { this.id = idCounter.getAndIncrement(); - this.name = name; - this.checkedIn = false; } @@ -36,7 +34,7 @@ public boolean isCheckedIn() { */ - public int setId(int id) { + /* public int setId(int id) { if (id > 0) { this.id = id; } else { @@ -45,6 +43,8 @@ public int setId(int id) { return id; } + */ + public void setName(String name) { if (name != null && !name.trim().isEmpty()) { this.name = name; @@ -53,6 +53,7 @@ public void setName(String name) { } } + public void checkIn() { this.checkedIn = true; } From 4d6bba6798c6f5fcfa720d625043882a368fee03 Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Sat, 21 Feb 2026 09:49:37 -0500 Subject: [PATCH 08/13] initial completion --- .../org/codedifferently/GlennAppointment.java | 48 -------------- .../codedifferently/GlennClinicSystem.java | 62 +++++++++++++++++++ .../org/codedifferently/GlennPatient.java | 9 --- 3 files changed, 62 insertions(+), 57 deletions(-) diff --git a/src/main/java/org/codedifferently/GlennAppointment.java b/src/main/java/org/codedifferently/GlennAppointment.java index dab3182..2ede95d 100644 --- a/src/main/java/org/codedifferently/GlennAppointment.java +++ b/src/main/java/org/codedifferently/GlennAppointment.java @@ -13,9 +13,6 @@ public GlennAppointment(String timeSlot, GlennPatient patient) { this.cancelled = false; } - public String getTimeSlot() { - return timeSlot; - } public GlennPatient getPatient() { return patient; @@ -29,51 +26,6 @@ public boolean isCancelled() { return cancelled; } - public void setPatient(GlennPatient patient) { - if (patient != null) { - this.patient = patient; - } else { - System.out.println("Invalid patient"); - } - } - - public void setTimeSlot(String timeSlot) { - if (timeSlot != null && !timeSlot.trim().isEmpty()) { - this.timeSlot = timeSlot; - } else { - System.out.println("Invalid Time"); - } - } - - public void setCompleted(boolean completed) { - if (!cancelled) { - this.completed = completed; - } else { - System.out.println("Appointment was cancelled"); - } - } - - public void setCancelled(boolean cancelled) { - if (!completed) { - this.cancelled = cancelled; - } else { - System.out.println("Appointment was completed"); - } - } - - 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"); diff --git a/src/main/java/org/codedifferently/GlennClinicSystem.java b/src/main/java/org/codedifferently/GlennClinicSystem.java index a1d9d59..0dbbf91 100644 --- a/src/main/java/org/codedifferently/GlennClinicSystem.java +++ b/src/main/java/org/codedifferently/GlennClinicSystem.java @@ -149,15 +149,66 @@ public void schedulePatient(){ public void cancelAppointment(){ + System.out.print("Enter Patient ID to cancel appointment: "); + int patientId = scan.nextInt(); + + int slotIndex = findSlotIndex(patientId); + if (slotIndex == -1) { + System.out.println("No scheduled appointment found for this patient."); + return; + } + + GlennAppointment appt = schedule[slotIndex]; + appt.cancel(); // marks canceled in the appointment object + schedule[slotIndex] = null; // frees the slot so it shows "Available" + + System.out.println("Appointment cancelled successfully."); + } public void dailySchedule(){ + System.out.println("Daily Schedule:"); + for (int i = 0; i < timeSlots.length; i++) { + if (schedule[i] == null) { + System.out.println(timeSlots[i] + " - Available"); + } else { + GlennAppointment appt = schedule[i]; + System.out.println(timeSlots[i] + " - " + appt.getPatient().getName()); + } + } + + } public void dailyReport(){ + int checkedInCount = 0; + for (GlennPatient p : patients) { + if (p.isCheckedIn()) checkedInCount++; + } + + int scheduledCount = 0; + for (GlennAppointment a : schedule) { + if (a != null) scheduledCount++; + } + + int completedCount = 0; + int cancelledCount = 0; + for (GlennAppointment a : appointments) { + if (a.isCompleted()) completedCount++; + if (a.isCancelled()) cancelledCount++; + } + + System.out.println("Daily Summary Report"); + System.out.println("-------------------------"); + System.out.println("Total Patients: " + patients.size()); + System.out.println("Total Patients Checked In: " + checkedInCount); + System.out.println("Appointments Scheduled (active): " + scheduledCount); + System.out.println("Appointments Completed: " + completedCount); + System.out.println("Appointments Cancelled: " + cancelledCount); + } private GlennPatient findPatientById(int id) { @@ -167,4 +218,15 @@ private GlennPatient findPatientById(int id) { return null; } + private int findSlotIndex(int patientId) { + for (int i = 0; i < schedule.length; i++) { + if (schedule[i] != null && schedule[i].getPatient().getId() == patientId) { + return i; + } + } + return -1; + } + + + } diff --git a/src/main/java/org/codedifferently/GlennPatient.java b/src/main/java/org/codedifferently/GlennPatient.java index a3d4f90..e88d58b 100644 --- a/src/main/java/org/codedifferently/GlennPatient.java +++ b/src/main/java/org/codedifferently/GlennPatient.java @@ -34,16 +34,7 @@ public boolean isCheckedIn() { */ - /* public int setId(int id) { - if (id > 0) { - this.id = id; - } else { - System.out.println("Invalid ID."); - } - return id; - } - */ public void setName(String name) { if (name != null && !name.trim().isEmpty()) { From ecdb5332c2c8c2d910883f84305dd85a0507e730 Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Sun, 22 Feb 2026 11:24:30 -0500 Subject: [PATCH 09/13] 5th commit with special part done --- .../org/codedifferently/GlennAppointment.java | 26 +++ .../org/codedifferently/GlennClinicApp.java | 36 ++-- .../codedifferently/GlennClinicSystem.java | 166 +++++++++++++----- .../org/codedifferently/GlennPatient.java | 13 +- 4 files changed, 179 insertions(+), 62 deletions(-) diff --git a/src/main/java/org/codedifferently/GlennAppointment.java b/src/main/java/org/codedifferently/GlennAppointment.java index 2ede95d..2047e62 100644 --- a/src/main/java/org/codedifferently/GlennAppointment.java +++ b/src/main/java/org/codedifferently/GlennAppointment.java @@ -14,6 +14,7 @@ public GlennAppointment(String timeSlot, GlennPatient patient) { } + public GlennPatient getPatient() { return patient; } @@ -26,6 +27,31 @@ public boolean isCancelled() { return cancelled; } + + public void setTimeSlot(String timeSlot) { + if (timeSlot != null && !timeSlot.trim().isEmpty()) { + this.timeSlot = timeSlot; + } else { + System.out.println("Invalid Time"); + } + } + + + + + 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"); diff --git a/src/main/java/org/codedifferently/GlennClinicApp.java b/src/main/java/org/codedifferently/GlennClinicApp.java index e26ad42..e761e82 100644 --- a/src/main/java/org/codedifferently/GlennClinicApp.java +++ b/src/main/java/org/codedifferently/GlennClinicApp.java @@ -42,29 +42,30 @@ public static void theClinic() { do { - System.out.println("Welcome to Derwin Bell's Community Clinic System"); + System.out.println("Welcome to Derwin & Glenn's Geek Squad"); System.out.println(""" - 1. Add New Patient - 2. View All Patients - 3. Check In Patient - 4. Search for Patient + 1. Add New Customer + 2. View All Customers + 3. Check In Customers + 4. Search for Customers 5. Schedule Appointment 6. Cancel Appointment - 7. View Daily Schedule - 8. Daily Report - 9. Exit"""); + 7. Complete Appointment + 8. View Daily Schedule + 9. Daily Report + 10. Exit"""); int choice = scan.nextInt(); switch (choice) { case 1: - System.out.println("Enter Patient Name: "); + System.out.println("Enter Customer's Name: "); String patientName = scan.next(); system.addPatient(patientName); break; case 2: - System.out.println("PATIENT LIST"); + System.out.println("Customer LIST"); system.patientList(); break; case 3: @@ -78,16 +79,18 @@ public static void theClinic() { system.schedulePatient(); break; case 6: - system.cancelAppointment(); break; case 7: + system.completeAppointment(); + case 8: system.dailySchedule(); break; - case 8: + case 9: system.dailyReport(); break; - case 9: + case 10: + System.out.println("Goodbye, Thanks For Coming!"); System.exit(0); break; default: @@ -114,9 +117,10 @@ public static void theClinic() { 4. Search for Patient 5. Schedule Appointment 6. Cancel Appointment -7. View Daily Schedule -8. Daily Report -9. Exit +7. Complete Appointment +8. View Daily Schedule +9. Daily Report +10. Exit Enter your choice: 1 diff --git a/src/main/java/org/codedifferently/GlennClinicSystem.java b/src/main/java/org/codedifferently/GlennClinicSystem.java index 0dbbf91..5c3b3aa 100644 --- a/src/main/java/org/codedifferently/GlennClinicSystem.java +++ b/src/main/java/org/codedifferently/GlennClinicSystem.java @@ -19,9 +19,20 @@ public class GlennClinicSystem { public void patientList(){ if (patients.isEmpty()) { - System.out.println("No patients found."); + System.out.println("No Customer found."); return; } + /* + for (int i =0; i < patients.size(); i++){ + GlennPatient p = new GlennPatient(); + + System.out.println("ID: " + p.getId() + + " | Name: " + p.getName() + + " | Checked In: " + p.isCheckedIn()); + + } + + */ for (GlennPatient p : patients) { @@ -40,15 +51,15 @@ public void addPatient(String name){ patients.add(p); - System.out.println("Patient added successfully!"); - System.out.println("Patient ID: " + p.getId()); + System.out.println("Customer added successfully!"); + System.out.println("Customer ID: " + p.getId()); } public void checkPatientIn(){ - System.out.println("Enter Patient ID to check"); + System.out.println("Enter Customer ID to check"); int patientId = scan.nextInt(); scan.nextLine(); // consume leftover newline @@ -57,15 +68,15 @@ public void checkPatientIn(){ for (GlennPatient p : patients) { if (p.getId() == patientId) { - p.checkIn(); // ✅ THIS is what actually changes checkedIn to true - System.out.println("Patient " + p.getName() + " checked in successfully."); + p.checkIn(); // changes checkedIn to true + System.out.println("Customer " + p.getName() + " checked in successfully."); found = true; break; // stop looping once we found them } } if (!found) { - System.out.println("No patient found with ID: " + patientId); + System.out.println("No Customer found with ID: " + patientId); } @@ -75,81 +86,118 @@ public void checkPatientIn(){ public void searchPatient(){ if (patients.isEmpty()) { - System.out.println("No patients exist yet. Add a patient first."); + System.out.println("No Customer exist yet. Add a patient first."); } - System.out.print("Enter Patient ID to check in: "); + System.out.print("Enter Customer ID to Find: "); int patientId = scan.nextInt(); for (GlennPatient p : patients){ if(p.getId() == patientId){ - p.checkIn(); - System.out.println("Patient " + p.getName() + " checked in successfully."); + + System.out.println("Customer " + p.getName() + " is in the Database"); } } } - public void schedulePatient(){ + public void schedulePatient(){ - if (patients.isEmpty()) { - System.out.println("No patients exist yet. Add a patient first."); + if(patients.isEmpty()){ + System.out.println("No customers exist yet."); return; } - System.out.println("Available Time Slots:"); - for (int i = 0; i < timeSlots.length; i++) { - String status = (schedule[i] == null) ? "Available" : "Booked"; - System.out.println((i + 1) + ". " + timeSlots[i] + " - " + status); - } + System.out.print("Enter Customer ID: "); + int patientId = scan.nextInt(); + scan.nextLine(); - System.out.print("Select a time slot (1-" + timeSlots.length + "): "); - int slotChoice = scan.nextInt(); + GlennPatient p = findPatientById(patientId); - if (slotChoice < 1 || slotChoice > timeSlots.length) { - System.out.println("Invalid time slot."); + if(p == null){ + System.out.println("Customer not found."); return; } - int slotIndex = slotChoice - 1; + if(!p.isCheckedIn()){ + System.out.println("Customer must be checked in first."); + return; + } + + System.out.print("Enter Priority (Emergency / Regular / Follow-Up): "); + String priority = scan.nextLine(); + p.setPriority(priority); + + + // EMERGENCY PATIENT + + if(p.getPriority().equals("EMERGENCY")){ + + int slotIndex = findEarliestAvailableSlot(); + + if(slotIndex == -1){ + System.out.println("No available slots today."); + return; + } + + GlennAppointment appt = new GlennAppointment(timeSlots[slotIndex], p); + schedule[slotIndex] = appt; + appointments.add(appt); - if (schedule[slotIndex] != null) { - System.out.println("That time slot is already booked. Please choose another."); + System.out.println("Emergency Customer scheduled at " + timeSlots[slotIndex]); return; } - System.out.print("Enter Patient ID: "); - int patientId = scan.nextInt(); - GlennPatient p = findPatientById(patientId); + // REGULAR OR FOLLOW-UP + + + System.out.println("Available Time Slots:"); + + for(int i = 0; i < timeSlots.length; i++){ + + String status = (schedule[i] == null) ? "Available" : "Booked"; + System.out.println((i+1) + ". " + timeSlots[i] + " - " + status); + } - if (p == null) { - System.out.println("Patient not found."); + System.out.print("Select Slot: "); + int slotChoice = scan.nextInt(); + + if(slotChoice < 1 || slotChoice > timeSlots.length){ + System.out.println("Invalid Slot"); return; } - if (!p.isCheckedIn()) { - System.out.println("Patient is not checked in yet. Please check them in first."); + int slotIndex = slotChoice - 1; + + if(schedule[slotIndex] != null){ + System.out.println("Slot already booked."); return; } - GlennAppointment appt = new GlennAppointment(timeSlots[slotIndex], p); + // FOLLOW-UP RULE + if(p.getPriority().equals("FOLLOW-UP")){ + if(!isFollowUpSlot(slotIndex)){ + System.out.println("Follow-up customers can only be scheduled at 1:00 PM or 2:00 PM"); + return; + } + } + + GlennAppointment appt = new GlennAppointment(timeSlots[slotIndex], p); schedule[slotIndex] = appt; appointments.add(appt); - System.out.println("Appointment scheduled at " - + timeSlots[slotIndex] + " for " + p.getName() + "."); - + System.out.println("Appointment scheduled at " + timeSlots[slotIndex]); } public void cancelAppointment(){ - System.out.print("Enter Patient ID to cancel appointment: "); + System.out.print("Enter Customer ID to cancel appointment: "); int patientId = scan.nextInt(); int slotIndex = findSlotIndex(patientId); @@ -166,6 +214,25 @@ public void cancelAppointment(){ } + public void completeAppointment(){ + + System.out.print("Enter Customer ID to complete appointment: "); + int patientId = scan.nextInt(); + + int slotIndex = findSlotIndex(patientId); + if (slotIndex == -1) { + System.out.println("No scheduled appointment found for this Customer."); + return; + } + + GlennAppointment appt = schedule[slotIndex]; + appt.complete(); // marks complete in the appointment object + schedule[slotIndex] = null; // frees the slot so it shows "Available" + + System.out.println("Appointment completed successfully."); + + } + public void dailySchedule(){ @@ -203,8 +270,8 @@ public void dailyReport(){ System.out.println("Daily Summary Report"); System.out.println("-------------------------"); - System.out.println("Total Patients: " + patients.size()); - System.out.println("Total Patients Checked In: " + checkedInCount); + System.out.println("Total Customers: " + patients.size()); + System.out.println("Total Customers Checked In: " + checkedInCount); System.out.println("Appointments Scheduled (active): " + scheduledCount); System.out.println("Appointments Completed: " + completedCount); System.out.println("Appointments Cancelled: " + cancelledCount); @@ -227,6 +294,25 @@ private int findSlotIndex(int patientId) { return -1; } + private int findEarliestAvailableSlot(){ + + for(int i = 0; i < schedule.length; i++){ + + if(schedule[i] == null){ + return i; + } + } + + return -1; + } + private boolean isFollowUpSlot(int slotIndex){ + + if(slotIndex == 3 || slotIndex == 4){ + return true; + } + + return false; + } } diff --git a/src/main/java/org/codedifferently/GlennPatient.java b/src/main/java/org/codedifferently/GlennPatient.java index e88d58b..d53f111 100644 --- a/src/main/java/org/codedifferently/GlennPatient.java +++ b/src/main/java/org/codedifferently/GlennPatient.java @@ -7,7 +7,7 @@ public class GlennPatient { private int id; private String name; private boolean checkedIn; - //private String priority; // Emergency , Reg, Follow + private String priority; // Emergency , Reg, Follow public GlennPatient() { this.id = idCounter.getAndIncrement(); @@ -28,13 +28,14 @@ public boolean isCheckedIn() { return checkedIn; } - /* public String getPriority() { - return priority; - } - - */ + public void setPriority(String priority){ + this.priority = priority.toUpperCase(); + } + public String getPriority(){ + return priority; + } public void setName(String name) { if (name != null && !name.trim().isEmpty()) { From ef3f3fbccbcf2cc23c6de792b88bdf0858b3af7d Mon Sep 17 00:00:00 2001 From: glenntyson Date: Sun, 22 Feb 2026 11:35:06 -0500 Subject: [PATCH 10/13] Added Comments for the Patient class --- src/main/java/org/codedifferently/GlennPatient.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/codedifferently/GlennPatient.java b/src/main/java/org/codedifferently/GlennPatient.java index d53f111..747e996 100644 --- a/src/main/java/org/codedifferently/GlennPatient.java +++ b/src/main/java/org/codedifferently/GlennPatient.java @@ -3,6 +3,7 @@ import java.util.concurrent.atomic.AtomicInteger; public class GlennPatient { + // Makes it so our id counter is going up by 1 everytime someone is added private static AtomicInteger idCounter = new AtomicInteger(1000); private int id; private String name; @@ -14,7 +15,7 @@ public GlennPatient() { this.checkedIn = false; } - +//Getters public int getId() { return id; } @@ -28,7 +29,7 @@ public boolean isCheckedIn() { return checkedIn; } - +//Setters public void setPriority(String priority){ this.priority = priority.toUpperCase(); } @@ -36,7 +37,7 @@ public void setPriority(String priority){ public String getPriority(){ return priority; } - +//Methods public void setName(String name) { if (name != null && !name.trim().isEmpty()) { this.name = name; @@ -50,7 +51,7 @@ public void checkIn() { this.checkedIn = true; } - +//toString public String toString() { return "ID: " + id + " | Name: " + name + " | " + "| Checked In: " + checkedIn; } From 28c34d55c2fb3c95c3babf0303054cd14c87a6fb Mon Sep 17 00:00:00 2001 From: glenntyson Date: Sun, 22 Feb 2026 11:37:15 -0500 Subject: [PATCH 11/13] Added Comments for the Appointment class --- src/main/java/org/codedifferently/GlennAppointment.java | 7 ++++--- src/main/java/org/codedifferently/GlennPatient.java | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/codedifferently/GlennAppointment.java b/src/main/java/org/codedifferently/GlennAppointment.java index 2047e62..4b0ae0a 100644 --- a/src/main/java/org/codedifferently/GlennAppointment.java +++ b/src/main/java/org/codedifferently/GlennAppointment.java @@ -6,6 +6,7 @@ public class GlennAppointment { private boolean completed; private boolean cancelled; + //Constructor public GlennAppointment(String timeSlot, GlennPatient patient) { this.timeSlot = timeSlot; this.patient = patient; @@ -14,7 +15,7 @@ public GlennAppointment(String timeSlot, GlennPatient patient) { } - +//Getters public GlennPatient getPatient() { return patient; } @@ -27,7 +28,7 @@ public boolean isCancelled() { return cancelled; } - +//Setter public void setTimeSlot(String timeSlot) { if (timeSlot != null && !timeSlot.trim().isEmpty()) { this.timeSlot = timeSlot; @@ -38,7 +39,7 @@ public void setTimeSlot(String timeSlot) { - +//Method public void complete() { if (cancelled) { System.out.println("Appointment was cancelled"); diff --git a/src/main/java/org/codedifferently/GlennPatient.java b/src/main/java/org/codedifferently/GlennPatient.java index 747e996..c324445 100644 --- a/src/main/java/org/codedifferently/GlennPatient.java +++ b/src/main/java/org/codedifferently/GlennPatient.java @@ -2,6 +2,7 @@ import java.util.concurrent.atomic.AtomicInteger; +//Constructor public class GlennPatient { // Makes it so our id counter is going up by 1 everytime someone is added private static AtomicInteger idCounter = new AtomicInteger(1000); From a0f84d6f1b9f40e21103539fb3fb61f1554efae5 Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Sun, 22 Feb 2026 13:52:45 -0500 Subject: [PATCH 12/13] final comments explaining the code --- .../org/codedifferently/GlennClinicApp.java | 116 +----------------- .../codedifferently/GlennClinicSystem.java | 44 ++++++- 2 files changed, 43 insertions(+), 117 deletions(-) diff --git a/src/main/java/org/codedifferently/GlennClinicApp.java b/src/main/java/org/codedifferently/GlennClinicApp.java index e761e82..62aa728 100644 --- a/src/main/java/org/codedifferently/GlennClinicApp.java +++ b/src/main/java/org/codedifferently/GlennClinicApp.java @@ -11,31 +11,8 @@ public static void main(String[] args) { theClinic(); } - /* - Quick cheat sheet: where methods belong -ClinicApp (controller) -display menu -get user input -call system methods -loop until exit - -ClinicSystem (logic + storage) -add/search/check-in patient -schedule/cancel appointments -prevent double booking -daily report calculations - -Patient (individual record) -checkIn() -getters/setters -toString()/display() - -Appointment (individual record) -cancel()/complete() -getters/setters -toString()/display() - */ +//The Method That Directs the user to all the methods in the System class public static void theClinic() { Scanner scan = new Scanner(System.in); GlennClinicSystem system = new GlennClinicSystem(); @@ -108,94 +85,3 @@ public static void theClinic() { } } -/* Example output -Welcome to Derwin Bell's Community Clinic System - -1. Add New Patient -2. View All Patients -3. Check In Patient -4. Search for Patient -5. Schedule Appointment -6. Cancel Appointment -7. Complete Appointment -8. View Daily Schedule -9. Daily Report -10. Exit - -Enter your choice: 1 - -Enter Patient Name: John Smith -Enter Phone Number: 555-1234 - -Patient added successfully! -Patient ID: 101 - -Enter your choice: 2 - -Patient List: -ID: 101 | Name: John Smith | Checked In: No -ID: 102 | Name: Sarah Johnson | Checked In: No - -Enter your choice: 3 - -Enter Patient ID to Check In: 101 - -Patient John Smith checked in successfully. - -Enter your choice: 4 - -Enter Patient ID to search: 102 - -Patient Found! -------------------------- -Patient ID: 102 -Name: Sarah Johnson -Phone Number: 555-7890 -Checked In: Yes -Appointment Time: 11:00 AM - -Enter your choice: 5 - -Available Time Slots: -1. 9:00 AM -2. 10:00 AM -3. 11:00 AM -4. 1:00 PM -5. 2:00 PM - -Select a time slot: 2 -Enter Patient ID: 101 - -Appointment scheduled at 10:00 AM. - -Enter your choice: 6 - -Enter Patient ID to cancel appointment: 102 - -Appointment for Sarah Johnson at 11:00 AM has been canceled successfully. - -Enter your choice: 7 - -Daily Schedule: -9:00 AM - Available -10:00 AM - John Smith -11:00 AM - Available -1:00 PM - Available -2:00 PM - Available - -Enter your choice: 8 - -Daily Summary Report -------------------------- -Total Patients Checked In: 1 -Appointments Scheduled: 1 -Appointments Completed: 0 -Waitlisted Patients: 0 - -Enter your choice: 9 - -Thank you for using the Community Clinic System. -Goodbye! - - - */ \ No newline at end of file diff --git a/src/main/java/org/codedifferently/GlennClinicSystem.java b/src/main/java/org/codedifferently/GlennClinicSystem.java index 5c3b3aa..5fda5d7 100644 --- a/src/main/java/org/codedifferently/GlennClinicSystem.java +++ b/src/main/java/org/codedifferently/GlennClinicSystem.java @@ -6,16 +6,28 @@ public class GlennClinicSystem { + // Properties + // (private and final because the values can't be changed nor accessed outside this class) + // Array List for the Glenn Patient class, this holds newly created patient objects + // that allows us to track the patients individual properties + // same for the Glenn Appointment Array List private final ArrayList patients = new ArrayList<>(); private final ArrayList appointments = new ArrayList<>(); + // Array made for time slots, this just holds the available times the user can book private final String[] timeSlots = {"9:00 AM", "10:00 AM", "11:00 AM", "1:00 PM", "2:00 PM"}; + // Array made with the Appointment Class, holds the properties of the class + // has the same amount of cells as the timeslot array private final GlennAppointment[] schedule = new GlennAppointment[timeSlots.length]; // Use ONE scanner for the system private final Scanner scan = new Scanner(System.in); + //Behaviors + //uses a for loop to search through the array + // print out ever patient object's name, id, and check in status + // if customers array is Empty say no customers found public void patientList(){ if (patients.isEmpty()) { @@ -43,6 +55,7 @@ public void patientList(){ } + //create new customers object, add it to the array, print out unique ID public void addPatient(String name){ @@ -57,6 +70,11 @@ public void addPatient(String name){ } + //ask user for ID + //search through the array to see if user given + // id matches any id of a patient object in the array + // call checkin to make true + // set found to true if not found say so public void checkPatientIn(){ System.out.println("Enter Customer ID to check"); @@ -83,7 +101,7 @@ public void checkPatientIn(){ } - + //Find customer with the given ID using for loop public void searchPatient(){ if (patients.isEmpty()) { System.out.println("No Customer exist yet. Add a patient first."); @@ -98,12 +116,24 @@ public void searchPatient(){ if(p.getId() == patientId){ System.out.println("Customer " + p.getName() + " is in the Database"); + System.out.println("ID: " + p.getId()); + System.out.println("Check In Status: " + p.isCheckedIn()); + System.out.println("Priority: " + p.getPriority()); } } } + //checks if customer array list is empty + // ask for customer ID from user + // if patient returns null it doesnt exist + // if Patient isnt checked in tell user to check in first + //ask for priority, set priority in the Patient object + // if emergency find the earliest available slot + // if regular you can choose any available slot + // follow ups can only be between 1pm or 2pm + public void schedulePatient(){ if(patients.isEmpty()){ @@ -195,6 +225,7 @@ public void schedulePatient(){ } +// deletes appointment object from the schedule array freeing up the spot in the cell public void cancelAppointment(){ System.out.print("Enter Customer ID to cancel appointment: "); @@ -214,6 +245,8 @@ public void cancelAppointment(){ } + + // deletes appointment object from the schedule array freeing up the spot in the cell public void completeAppointment(){ System.out.print("Enter Customer ID to complete appointment: "); @@ -234,6 +267,8 @@ public void completeAppointment(){ } +// goes through the timeslots checking if its avalible +// if not show the name of the customers the took up said spot public void dailySchedule(){ System.out.println("Daily Schedule:"); @@ -248,7 +283,10 @@ public void dailySchedule(){ } - +//tells you the amount of customers checked in +//as well as patients currently scheduled +//completed and cancelled appointments +// total number of customers public void dailyReport(){ int checkedInCount = 0; @@ -278,6 +316,7 @@ public void dailyReport(){ } + // Methods for reused code throughout the program private GlennPatient findPatientById(int id) { for (GlennPatient p : patients) { if (p.getId() == id) return p; @@ -305,6 +344,7 @@ private int findEarliestAvailableSlot(){ return -1; } + private boolean isFollowUpSlot(int slotIndex){ if(slotIndex == 3 || slotIndex == 4){ From a63e6bec7d652bc48102f066d6d79aed15c5b7fb Mon Sep 17 00:00:00 2001 From: Derwin Bell Date: Sat, 28 Feb 2026 21:04:24 -0500 Subject: [PATCH 13/13] bankaccount lab creditcard complete --- src/main/java/org/codedifferently/GlennClinicApp.java | 3 --- src/main/java/org/codedifferently/GlennClinicSystem.java | 6 ++++-- src/main/java/org/codedifferently/GlennPatient.java | 4 +++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/codedifferently/GlennClinicApp.java b/src/main/java/org/codedifferently/GlennClinicApp.java index 62aa728..7047165 100644 --- a/src/main/java/org/codedifferently/GlennClinicApp.java +++ b/src/main/java/org/codedifferently/GlennClinicApp.java @@ -1,7 +1,4 @@ package org.codedifferently; - - - import java.util.Scanner; public class GlennClinicApp{ diff --git a/src/main/java/org/codedifferently/GlennClinicSystem.java b/src/main/java/org/codedifferently/GlennClinicSystem.java index 5fda5d7..6c89e15 100644 --- a/src/main/java/org/codedifferently/GlennClinicSystem.java +++ b/src/main/java/org/codedifferently/GlennClinicSystem.java @@ -7,7 +7,9 @@ public class GlennClinicSystem { // Properties + // (private and final because the values can't be changed nor accessed outside this class) + // Array List for the Glenn Patient class, this holds newly created patient objects // that allows us to track the patients individual properties // same for the Glenn Appointment Array List @@ -25,7 +27,7 @@ public class GlennClinicSystem { //Behaviors - //uses a for loop to search through the array + //uses a for each loop to search through the array // print out ever patient object's name, id, and check in status // if customers array is Empty say no customers found public void patientList(){ @@ -285,7 +287,7 @@ public void dailySchedule(){ } //tells you the amount of customers checked in //as well as patients currently scheduled -//completed and cancelled appointments +//completed and canceled appointments // total number of customers public void dailyReport(){ diff --git a/src/main/java/org/codedifferently/GlennPatient.java b/src/main/java/org/codedifferently/GlennPatient.java index c324445..d15393b 100644 --- a/src/main/java/org/codedifferently/GlennPatient.java +++ b/src/main/java/org/codedifferently/GlennPatient.java @@ -2,8 +2,9 @@ import java.util.concurrent.atomic.AtomicInteger; -//Constructor + public class GlennPatient { + //Properties // Makes it so our id counter is going up by 1 everytime someone is added private static AtomicInteger idCounter = new AtomicInteger(1000); private int id; @@ -11,6 +12,7 @@ public class GlennPatient { private boolean checkedIn; private String priority; // Emergency , Reg, Follow +//Constructor public GlennPatient() { this.id = idCounter.getAndIncrement(); this.checkedIn = false;