From 9ed1a0891df67a68b8031fd771c294976aa32961 Mon Sep 17 00:00:00 2001 From: Kenny Edelin Date: Thu, 19 Feb 2026 17:31:16 -0500 Subject: [PATCH 01/17] Variables --- .../java/org/codedifferently/KennyPatient.java | 10 ++++++++++ src/main/java/org/codedifferently/Main.java | 17 ----------------- 2 files changed, 10 insertions(+), 17 deletions(-) create mode 100644 src/main/java/org/codedifferently/KennyPatient.java delete mode 100644 src/main/java/org/codedifferently/Main.java diff --git a/src/main/java/org/codedifferently/KennyPatient.java b/src/main/java/org/codedifferently/KennyPatient.java new file mode 100644 index 0000000..a2cfd55 --- /dev/null +++ b/src/main/java/org/codedifferently/KennyPatient.java @@ -0,0 +1,10 @@ +package org.codedifferently; + +public class KennyPatient { + + private int id; + + private String name; + + private boolean checkedIn; + diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java deleted file mode 100644 index 435139b..0000000 --- a/src/main/java/org/codedifferently/Main.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.codedifferently; - -//TIP To Run code, press or -// click the icon in the gutter. -public class Main { - 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); - } - } -} \ No newline at end of file From f8aab09c633016fe8752390a2f3b1431acd942dc Mon Sep 17 00:00:00 2001 From: Bryant Ferguson Date: Fri, 20 Feb 2026 14:28:12 -0500 Subject: [PATCH 02/17] Added Patient class to uml diagram --- src/diagram.puml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/diagram.puml diff --git a/src/diagram.puml b/src/diagram.puml new file mode 100644 index 0000000..bf46c6b --- /dev/null +++ b/src/diagram.puml @@ -0,0 +1,19 @@ +@startuml + +class Patient { + - name : String + - species: String + - ownersPhoneNumber : String + + + getName() : String + + getSpecies() : String + + getOwnersPhoneNumber() : String + + setName() : String + + setSpecies() : String + + setOwnersPhoneNumber():String +} + + + + +@enduml \ No newline at end of file From d75065541b6846c5ba7e071ccc93dffff2ab127c Mon Sep 17 00:00:00 2001 From: Bryant Ferguson Date: Sat, 21 Feb 2026 10:01:33 -0500 Subject: [PATCH 03/17] Added checkIn field to Patient class --- src/diagram.puml | 59 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 4 deletions(-) diff --git a/src/diagram.puml b/src/diagram.puml index bf46c6b..c4306ce 100644 --- a/src/diagram.puml +++ b/src/diagram.puml @@ -2,18 +2,69 @@ class Patient { - name : String - - species: String + - species : String - ownersPhoneNumber : String + - appointments : ArrayList + - checkedIn: boolean + + + Patient(name : String, species : String, ownersPhoneNumber : String) + getName() : String + getSpecies() : String + getOwnersPhoneNumber() : String - + setName() : String - + setSpecies() : String - + setOwnersPhoneNumber():String + + getCheckedIn() : boolean + + + setName(name : String) : void + + setSpecies(species : String) : void + + setOwnersPhoneNumber(ownersPhoneNumber : String) : void + + setCheckedIn(checkedIn: String) : void } +class Appointment { + - reason : String + - date : String + - time : String + + + Appointment(reason : String, date : String) + + + getReason() : String + + getDate() : String + + getTime() : String + + + setReason(reason : String) : void + + setDate(date : String) : void + + setDate(time : String) : void + +} + +class ClinicSystem { + - patients : ArrayList + - waitingList : ArrayList +} +class YourNameClinicApp { + + main(args : String[]) : void +} + +' ========================================= +' RELATIONSHIPS EXPLAINED +' ========================================= + +' One Patient has zero or many Appointments. +' "1" means one Patient. +' "0..*" means that Patient can have zero or many Appointment objects. +' *-- means composition (Appointments belong to the Patient and cannot exist without it). +YourNamePatient "1" *-- "0..*" YourNameAppointment + +' One ClinicSystem manages zero or many Patients. +' "1" means one ClinicSystem. +' "0..*" means the system can manage zero or many Patient objects. +' o-- means aggregation (Patients can exist independently of the ClinicSystem). +YourNameClinicSystem "1" o-- "0..*" YourNamePatient +' ClinicApp depends on ClinicSystem. +' This means the main application class uses ClinicSystem to run the program. +' --> represents a dependency relationship. +YourNameClinicApp --> YourNameClinicSystem @enduml \ No newline at end of file From c14d2e783f853167add8643210c629d96c00c028 Mon Sep 17 00:00:00 2001 From: Kenny Edelin Date: Sat, 21 Feb 2026 10:11:56 -0500 Subject: [PATCH 04/17] Made patient class --- .../org/codedifferently/KennyPatient.java | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/codedifferently/KennyPatient.java b/src/main/java/org/codedifferently/KennyPatient.java index a2cfd55..e74a2df 100644 --- a/src/main/java/org/codedifferently/KennyPatient.java +++ b/src/main/java/org/codedifferently/KennyPatient.java @@ -1,10 +1,54 @@ package org.codedifferently; -public class KennyPatient { + public class KennyPatient { - private int id; + private int id; - private String name; + private String name; - private boolean checkedIn; + private boolean checkedIn; + + public KennyPatient(int id, String name) { + this.id = id; + + 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 void setName(String name) { + this.name = name; + + } + + + @Override + public String toString() { + return "KennyPatient{" + + "id=" + id + + ", name='" + name + '\'' + + ", checkedIn=" + checkedIn + + '}'; + } + } From 7e5c178510ed51e68237864d078230932c048f1c Mon Sep 17 00:00:00 2001 From: mesheikbrown Date: Sat, 21 Feb 2026 10:25:21 -0500 Subject: [PATCH 05/17] added test file --- src/main/java/test.java | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/main/java/test.java diff --git a/src/main/java/test.java b/src/main/java/test.java new file mode 100644 index 0000000..53ba7f6 --- /dev/null +++ b/src/main/java/test.java @@ -0,0 +1,2 @@ +public class test { +} From 00b7a3387a54690c016e3823f2ca623568afce23 Mon Sep 17 00:00:00 2001 From: Kenny Edelin Date: Sat, 21 Feb 2026 10:46:47 -0500 Subject: [PATCH 06/17] Test --- src/main/java/org/codedifferently/KennyPatient.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/org/codedifferently/KennyPatient.java b/src/main/java/org/codedifferently/KennyPatient.java index e74a2df..6c7ecb6 100644 --- a/src/main/java/org/codedifferently/KennyPatient.java +++ b/src/main/java/org/codedifferently/KennyPatient.java @@ -15,6 +15,11 @@ public KennyPatient(int id, String name) { this.name = name; this.checkedIn = false; + + + + + } From d499a0e7e13de60b7caaca0776dc9c8d58b44e21 Mon Sep 17 00:00:00 2001 From: Kenny Edelin Date: Sat, 21 Feb 2026 11:09:36 -0500 Subject: [PATCH 07/17] Patient Class Updated --- .../org/codedifferently/KennyPatient.java | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/codedifferently/KennyPatient.java b/src/main/java/org/codedifferently/KennyPatient.java index 6c7ecb6..290d3e4 100644 --- a/src/main/java/org/codedifferently/KennyPatient.java +++ b/src/main/java/org/codedifferently/KennyPatient.java @@ -1,57 +1,68 @@ package org.codedifferently; - public class KennyPatient { +import java.util.ArrayList; - private int id; +public class KennyPatient { + + private String species; private String name; private boolean checkedIn; + private ArrayList appointments ; - public KennyPatient(int id, String name) { - this.id = id; - - this.name = name; + private String ownersPhoneNumber; - this.checkedIn = false; + public KennyPatient(String species, String name, boolean checkedIn, String ownersPhoneNumber) { + this.species = species; + this.name = name; + this.checkedIn = checkedIn; + this.ownersPhoneNumber = ownersPhoneNumber; } - public int getId() { - return id; + public String getSpecies() { + return species; } public String getName() { return name; } - public boolean isCheckedIn() { + public boolean getCheckedIn() { return checkedIn; } + public String getOwnersPhoneNumber(){return ownersPhoneNumber;} - public void checkIn() { - this.checkedIn = true; + public void setCheckedIn(Boolean checkedIn) { + this.checkedIn = checkedIn; } public void setName(String name) { this.name = name; + } + public void setOwnersPhoneNumber(String ownersPhoneNumber){ + this.ownersPhoneNumber = ownersPhoneNumber; + } + public void setSpecies(String species){ + this.species = species; } @Override public String toString() { return "KennyPatient{" + - "id=" + id + + "id=" + species + ", name='" + name + '\'' + ", checkedIn=" + checkedIn + '}'; From 69bbd35978cbad53177b7e19d8db44619e470f5f Mon Sep 17 00:00:00 2001 From: Bryant Ferguson Date: Sat, 21 Feb 2026 11:20:42 -0500 Subject: [PATCH 08/17] Updated Diagram --- src/diagram.puml | 8 ++++---- src/main/java/org/codedifferently/KennyPatient.java | 6 +----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/diagram.puml b/src/diagram.puml index c4306ce..0578a95 100644 --- a/src/diagram.puml +++ b/src/diagram.puml @@ -5,19 +5,19 @@ class Patient { - species : String - ownersPhoneNumber : String - appointments : ArrayList - - checkedIn: boolean + - checkedIn : boolean - + Patient(name : String, species : String, ownersPhoneNumber : String) + + Patient(name : String, species : String, ownersPhoneNumber : String, checkedIn : boolean) + getName() : String + getSpecies() : String + getOwnersPhoneNumber() : String - + getCheckedIn() : boolean + + isCheckedIn() : boolean + setName(name : String) : void + setSpecies(species : String) : void + setOwnersPhoneNumber(ownersPhoneNumber : String) : void - + setCheckedIn(checkedIn: String) : void + + setCheckedIn(checkedIn : boolean) : void } class Appointment { diff --git a/src/main/java/org/codedifferently/KennyPatient.java b/src/main/java/org/codedifferently/KennyPatient.java index 6c7ecb6..d6935af 100644 --- a/src/main/java/org/codedifferently/KennyPatient.java +++ b/src/main/java/org/codedifferently/KennyPatient.java @@ -15,11 +15,7 @@ public KennyPatient(int id, String name) { this.name = name; this.checkedIn = false; - - - - - + } From 7a6b91a38bfbd50db3ab703082319148709908e1 Mon Sep 17 00:00:00 2001 From: mesheikbrown Date: Sat, 21 Feb 2026 15:09:22 -0500 Subject: [PATCH 09/17] added variables --- .../org/codedifferently/MesheikAppointment.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/org/codedifferently/MesheikAppointment.java diff --git a/src/main/java/org/codedifferently/MesheikAppointment.java b/src/main/java/org/codedifferently/MesheikAppointment.java new file mode 100644 index 0000000..6d3bb21 --- /dev/null +++ b/src/main/java/org/codedifferently/MesheikAppointment.java @@ -0,0 +1,16 @@ +package org.codedifferently; + +public class MesheikAppointment { + + //Setting our variables up + private String date; + private String time; + private String reason; + + public MesheikAppointment(String date, String time, String reason){ + this.date = date; + this.time = time; + this.reason = reason; + } + +}//ends class From 70c9dcfd2acb0fdda43256f79f9be4395ea87a6b Mon Sep 17 00:00:00 2001 From: mesheikbrown Date: Sat, 21 Feb 2026 15:13:58 -0500 Subject: [PATCH 10/17] Getters and Setters done --- .../codedifferently/MesheikAppointment.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/org/codedifferently/MesheikAppointment.java b/src/main/java/org/codedifferently/MesheikAppointment.java index 6d3bb21..e159346 100644 --- a/src/main/java/org/codedifferently/MesheikAppointment.java +++ b/src/main/java/org/codedifferently/MesheikAppointment.java @@ -13,4 +13,31 @@ public MesheikAppointment(String date, String time, String reason){ this.reason = reason; } + //Getters + public String getDate() { + return date; + } + + public String getTime() { + return time; + } + + public String getReason() { + return reason; + } + + + //Setters + public void setDate(String date) { + this.date = date; + } + + public void setTime(String time) { + this.time = time; + } + + public void setReason(String reason) { + this.reason = reason; + } + }//ends class From b8e26f6df1cec95e7ee0394b9e3f1e307f194c13 Mon Sep 17 00:00:00 2001 From: mesheikbrown Date: Sat, 21 Feb 2026 15:27:07 -0500 Subject: [PATCH 11/17] Appointment Class is set up. --- src/main/java/org/codedifferently/MesheikAppointment.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/codedifferently/MesheikAppointment.java b/src/main/java/org/codedifferently/MesheikAppointment.java index e159346..e3f38b6 100644 --- a/src/main/java/org/codedifferently/MesheikAppointment.java +++ b/src/main/java/org/codedifferently/MesheikAppointment.java @@ -1,19 +1,21 @@ package org.codedifferently; +// This class represents one appointment public class MesheikAppointment { - //Setting our variables up + //Setting our appointment variables up private String date; private String time; private String reason; + // Constructor runs when an appointment is created public MesheikAppointment(String date, String time, String reason){ this.date = date; this.time = time; this.reason = reason; } - //Getters + //Getters: how we get our appointments public String getDate() { return date; } @@ -27,7 +29,7 @@ public String getReason() { } - //Setters + //Setters: How we change or update our appointments public void setDate(String date) { this.date = date; } From e73f3711805fa9f9ce55517a0cda865ffc45ad2f Mon Sep 17 00:00:00 2001 From: Bryant Ferguson Date: Sun, 22 Feb 2026 19:35:41 -0500 Subject: [PATCH 12/17] deleted the test class and added the clinicapp class --- src/main/java/org/codedifferently/BryantClinicApp.java | 4 ++++ src/main/java/test.java | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/codedifferently/BryantClinicApp.java delete mode 100644 src/main/java/test.java diff --git a/src/main/java/org/codedifferently/BryantClinicApp.java b/src/main/java/org/codedifferently/BryantClinicApp.java new file mode 100644 index 0000000..9e32634 --- /dev/null +++ b/src/main/java/org/codedifferently/BryantClinicApp.java @@ -0,0 +1,4 @@ +package org.codedifferently; + +public class BryantClinicApp { +} diff --git a/src/main/java/test.java b/src/main/java/test.java deleted file mode 100644 index 53ba7f6..0000000 --- a/src/main/java/test.java +++ /dev/null @@ -1,2 +0,0 @@ -public class test { -} From 5c0ade85025d8e98ead0b3b1cc2bdd36b6675093 Mon Sep 17 00:00:00 2001 From: Bryant Ferguson Date: Sun, 22 Feb 2026 21:32:09 -0500 Subject: [PATCH 13/17] Removed appointments array from the patient class to the clinicsystem class and added basic methods for clinic systems --- .../codedifferently/BryantClinicSystem.java | 51 +++++++++++++++++++ .../org/codedifferently/KennyPatient.java | 8 +-- 2 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 src/main/java/org/codedifferently/BryantClinicSystem.java diff --git a/src/main/java/org/codedifferently/BryantClinicSystem.java b/src/main/java/org/codedifferently/BryantClinicSystem.java new file mode 100644 index 0000000..21a38ee --- /dev/null +++ b/src/main/java/org/codedifferently/BryantClinicSystem.java @@ -0,0 +1,51 @@ +package org.codedifferently; + +import java.util.ArrayList; + +public class BryantClinicSystem { + + private ArrayList patients; + private ArrayList waitingList; + private ArrayList appointments; + + public BryantClinicSystem() { + + this.patients = new ArrayList<>(); + this.waitingList = new ArrayList<>(); + this.appointments = new ArrayList<>(); + + // Preloaded patients + KennyPatient p1 = new KennyPatient("Dog", "Buddy", false, "3025551111"); + KennyPatient p2 = new KennyPatient("Cat", "Luna", false, "3025552222"); + patients.add(p1); + patients.add(p2); + + // Preloaded appointments + MesheikAppointment a1 = new MesheikAppointment("12/10/2026", "9:00AM", "Checkup"); + MesheikAppointment a2 = new MesheikAppointment("12/10/2026", "10:00AM", "Vaccination"); + appointments.add(a1); + appointments.add(a2); + } + + public void scheduleAppointment(MesheikAppointment appointment) { + appointments.add(appointment); + } + + public void cancelAppointment(MesheikAppointment appointment) { + appointments.remove(appointment); + } + + public void addedToWaitingList(KennyPatient patient) { + waitingList.add(patient); + } + + public void viewAllPatients(){ + + } + + public void lookUpPatient(){ + + } + + +} diff --git a/src/main/java/org/codedifferently/KennyPatient.java b/src/main/java/org/codedifferently/KennyPatient.java index 325ad9f..036fabb 100644 --- a/src/main/java/org/codedifferently/KennyPatient.java +++ b/src/main/java/org/codedifferently/KennyPatient.java @@ -10,8 +10,6 @@ public class KennyPatient { private boolean checkedIn; - //private ArrayList appointments ; - private String ownersPhoneNumber; @@ -26,7 +24,6 @@ public KennyPatient(String species, String name, boolean checkedIn, String owner } - public String getSpecies() { return species; } @@ -41,12 +38,10 @@ public boolean getCheckedIn() { public String getOwnersPhoneNumber(){return ownersPhoneNumber;} - public void setCheckedIn(Boolean checkedIn) { this.checkedIn = checkedIn; } - public void setName(String name) { this.name = name; } @@ -58,8 +53,7 @@ public void setSpecies(String species){ this.species = species; } - - @Override + @Override public String toString() { return "KennyPatient{" + "id=" + species + From e36096308901208b1405d8f0af3e885397ac69e5 Mon Sep 17 00:00:00 2001 From: Bryant Ferguson Date: Sun, 22 Feb 2026 23:36:27 -0500 Subject: [PATCH 14/17] Added multiple functions to clinicsystem class --- .../codedifferently/BryantClinicSystem.java | 30 +++++++++++++++++-- .../org/codedifferently/KennyPatient.java | 25 +++++++++++----- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/codedifferently/BryantClinicSystem.java b/src/main/java/org/codedifferently/BryantClinicSystem.java index 21a38ee..1d469b5 100644 --- a/src/main/java/org/codedifferently/BryantClinicSystem.java +++ b/src/main/java/org/codedifferently/BryantClinicSystem.java @@ -39,13 +39,37 @@ public void addedToWaitingList(KennyPatient patient) { waitingList.add(patient); } - public void viewAllPatients(){ + public void addPatient(KennyPatient patient){ + patients.add(patient); + } + public void viewAllPatients(){ + for (KennyPatient patient : patients) { + patient.displayInfo(); + } } - public void lookUpPatient(){ + public void lookUpPatient(String name, String phoneNumber){ + for (KennyPatient patient : patients) { + if (name.equals(patient.getName()) && phoneNumber.equals(patient.getOwnersPhoneNumber())) { + patient.displayInfo(); + } + } + } + public void lookUpPatientById(int id){ + for (KennyPatient patient : patients) { + if (patient.getPatientId() == id) { + patient.displayInfo(); + return; //exits the method early + } + } + System.out.println("Patient not found."); } -} + public void checkInPatient(KennyPatient patient){ + patient.setCheckedIn(true); + } + +}// ends class diff --git a/src/main/java/org/codedifferently/KennyPatient.java b/src/main/java/org/codedifferently/KennyPatient.java index 036fabb..04ec905 100644 --- a/src/main/java/org/codedifferently/KennyPatient.java +++ b/src/main/java/org/codedifferently/KennyPatient.java @@ -12,6 +12,8 @@ public class KennyPatient { private String ownersPhoneNumber; + private int patientId; + private int idCounter = 1; public KennyPatient(String species, String name, boolean checkedIn, String ownersPhoneNumber) { this.species = species; @@ -22,6 +24,7 @@ public KennyPatient(String species, String name, boolean checkedIn, String owner this.ownersPhoneNumber = ownersPhoneNumber; + this.patientId = idCounter++; } public String getSpecies() { @@ -36,6 +39,10 @@ public boolean getCheckedIn() { return checkedIn; } + public int getPatientId() { + return patientId; + } + public String getOwnersPhoneNumber(){return ownersPhoneNumber;} public void setCheckedIn(Boolean checkedIn) { @@ -53,12 +60,14 @@ public void setSpecies(String species){ this.species = species; } - @Override - public String toString() { - return "KennyPatient{" + - "id=" + species + - ", name='" + name + '\'' + - ", checkedIn=" + checkedIn + - '}'; + public void displayInfo() { + System.out.println("Patient ID: " + patientId); + System.out.println("Pet Name: " + name); + System.out.println("Species: " + species); + System.out.println("Owner's Phone Number: " + ownersPhoneNumber); + System.out.println("Checked In: " + checkedIn); + System.out.println(); } - } + + +} From e6f4ee8ad3ddf0a01622032df4d9024dafb05250 Mon Sep 17 00:00:00 2001 From: Bryant Ferguson Date: Mon, 23 Feb 2026 01:42:20 -0500 Subject: [PATCH 15/17] finished clinicSystem class --- .../codedifferently/BryantClinicSystem.java | 127 +++++++++++++++++- .../org/codedifferently/KennyPatient.java | 5 +- .../codedifferently/MesheikAppointment.java | 11 ++ 3 files changed, 135 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/codedifferently/BryantClinicSystem.java b/src/main/java/org/codedifferently/BryantClinicSystem.java index 1d469b5..ec15b00 100644 --- a/src/main/java/org/codedifferently/BryantClinicSystem.java +++ b/src/main/java/org/codedifferently/BryantClinicSystem.java @@ -7,6 +7,7 @@ public class BryantClinicSystem { private ArrayList patients; private ArrayList waitingList; private ArrayList appointments; + private String[] dailyTimeSlots = {"9:00AM", "10:00AM", "11:00AM", "1:00PM", "2:00PM", "3:00PM"}; public BryantClinicSystem() { @@ -27,18 +28,108 @@ public BryantClinicSystem() { appointments.add(a2); } - public void scheduleAppointment(MesheikAppointment appointment) { - appointments.add(appointment); + public boolean isValidTime(String time) { + for (String slot : dailyTimeSlots) { + if (slot.equalsIgnoreCase(time)) { + return true; + } + } + return false; + } + + public void scheduleAppointment(String date, String time, String reason) { + // checks for bad input + if (date == null || date.isEmpty() || + time == null || time.isEmpty() || + reason == null || reason.isEmpty()) { + System.out.println("Invalid input. All fields are required to schedule an appointment."); + return; + } + + // Validate time exists in daily schedule + if (!isValidTime(time)) { + System.out.println("Invalid time slot."); + return; + } + + // Prevent double booking + for (MesheikAppointment appointment : appointments) { + if (appointment.getDate().equals(date) && appointment.getTime().equalsIgnoreCase(time)) { + System.out.println("That time slot is already booked on this date."); + return; + } + } + + // If the appointment is valid and not booked, schedule the appointment + MesheikAppointment newAppointment = new MesheikAppointment(date, time, reason); + appointments.add(newAppointment); + System.out.println("Appointment scheduled successfully."); + } + + public void viewFullSchedule() { + if (appointments.isEmpty()) { + System.out.println("No appointments are scheduled."); + return; + } + + for (MesheikAppointment appointment : appointments) { + System.out.println("Date: " + appointment.getDate()); + System.out.println("Time: " + appointment.getTime()); + System.out.println("Reason: " + appointment.getReason()); + System.out.println("---------------------------"); + } + } + + public void cancelAppointment(String date, String time) { + for (int i = 0; i < appointments.size(); i++) { + MesheikAppointment appointment = appointments.get(i); + if (appointment.getDate().equals(date) && appointment.getTime().equalsIgnoreCase(time)) { + if (appointment.isCompleted()) { + System.out.println("Cannot cancel a completed appointment."); + return; + } + appointments.remove(i); + System.out.println("The Appointment was cancelled."); + return; + } + } + System.out.println("Appointment not found."); } - public void cancelAppointment(MesheikAppointment appointment) { - appointments.remove(appointment); + public void completeAppointment(String date, String time) { + for (MesheikAppointment appointment : appointments) { + if (appointment.getDate().equals(date) && appointment.getTime().equalsIgnoreCase(time)) { + if (appointment.isCompleted()) { + System.out.println("Appointment already completed."); + return; + } + appointment.markCompleted(); + System.out.println("Appointment marked as completed."); + return; + } + } + + System.out.println("Appointment not found."); } + public void addedToWaitingList(KennyPatient patient) { waitingList.add(patient); + System.out.println("Patient added to waiting list."); + } + + public void viewWaitList() { + if (waitingList.isEmpty()) { + System.out.println("Waitlist is empty."); + return; + } + System.out.println("---- Waiting List ----"); + for (KennyPatient patient : waitingList) { + patient.displayInfo(); + } } + public void addPatient(KennyPatient patient){ patients.add(patient); } @@ -67,9 +158,35 @@ public void lookUpPatientById(int id){ System.out.println("Patient not found."); } + public void checkInPatient(KennyPatient patient) { + if (patient.isCheckedIn()) { + System.out.println("Patient already checked in."); + return; + } - public void checkInPatient(KennyPatient patient){ patient.setCheckedIn(true); + System.out.println("Patient checked in successfully."); + } + + public void dailySummary(String date) { + int total=0, completed=0, pending=0; + + for (MesheikAppointment appointment : appointments) { + if (appointment.getDate().equals(date)) { + total++; + + if (appointment.isCompleted()) { + completed++; + } else { + pending++; + } + } + } + + System.out.println("----- Daily Summary for " + date + " -----"); + System.out.println("Total Appointments: " + total); + System.out.println("Completed Appointments: " + completed); + System.out.println("Pending Appointments: " + pending); } }// ends class diff --git a/src/main/java/org/codedifferently/KennyPatient.java b/src/main/java/org/codedifferently/KennyPatient.java index 04ec905..c774bd6 100644 --- a/src/main/java/org/codedifferently/KennyPatient.java +++ b/src/main/java/org/codedifferently/KennyPatient.java @@ -35,7 +35,7 @@ public String getName() { return name; } - public boolean getCheckedIn() { + public boolean isCheckedIn() { return checkedIn; } @@ -66,8 +66,7 @@ public void displayInfo() { System.out.println("Species: " + species); System.out.println("Owner's Phone Number: " + ownersPhoneNumber); System.out.println("Checked In: " + checkedIn); - System.out.println(); - } + System.out.println("---------------------------"); } } diff --git a/src/main/java/org/codedifferently/MesheikAppointment.java b/src/main/java/org/codedifferently/MesheikAppointment.java index e3f38b6..ae79b1f 100644 --- a/src/main/java/org/codedifferently/MesheikAppointment.java +++ b/src/main/java/org/codedifferently/MesheikAppointment.java @@ -7,12 +7,14 @@ public class MesheikAppointment { private String date; private String time; private String reason; + private boolean completed; // Constructor runs when an appointment is created public MesheikAppointment(String date, String time, String reason){ this.date = date; this.time = time; this.reason = reason; + this.completed = false; } //Getters: how we get our appointments @@ -28,6 +30,10 @@ public String getReason() { return reason; } + public boolean isCompleted() { + return completed; + } + //Setters: How we change or update our appointments public void setDate(String date) { @@ -42,4 +48,9 @@ public void setReason(String reason) { this.reason = reason; } + public void markCompleted() { + this.completed = true; + } + + }//ends class From 058e98195c6f0c36020e833e4f71fd23af67976f Mon Sep 17 00:00:00 2001 From: Bryant Ferguson Date: Mon, 23 Feb 2026 03:57:35 -0500 Subject: [PATCH 16/17] finished up my portion of the assignment --- src/diagram.puml | 56 ++++--- .../org/codedifferently/BryantClinicApp.java | 144 +++++++++++++++++- .../codedifferently/BryantClinicSystem.java | 69 +++++++-- .../org/codedifferently/KennyPatient.java | 13 +- .../codedifferently/MesheikAppointment.java | 6 +- 5 files changed, 254 insertions(+), 34 deletions(-) diff --git a/src/diagram.puml b/src/diagram.puml index 0578a95..ddfb407 100644 --- a/src/diagram.puml +++ b/src/diagram.puml @@ -1,14 +1,15 @@ @startuml class Patient { + - patientId : int - name : String - species : String - ownersPhoneNumber : String - - appointments : ArrayList - checkedIn : boolean - + Patient(name : String, species : String, ownersPhoneNumber : String, checkedIn : boolean) + + Patient(species : String, name : String, checkedIn : boolean, ownersPhoneNumber : String) + + getPatientId() : int + getName() : String + getSpecies() : String + getOwnersPhoneNumber() : String @@ -24,24 +25,42 @@ class Appointment { - reason : String - date : String - time : String + - completed : boolean - + Appointment(reason : String, date : String) + + Appointment(date : String, time : String, reason : String) + getReason() : String + getDate() : String + getTime() : String + + isCompleted() : boolean - + setReason(reason : String) : void - + setDate(date : String) : void - + setDate(time : String) : void - + + markCompleted() : void } class ClinicSystem { - patients : ArrayList - waitingList : ArrayList + - appointments : ArrayList + - dailyTimeSlots : String[] + + + ClinicSystem() + + + addPatient(patient : Patient) : void + + viewAllPatients() : void + + lookUpPatient(name : String, phoneNumber : String) : void + + lookUpPatientById(id : int) : void + + checkInPatient(patient : Patient) : void + + + scheduleAppointment(date : String, time : String, reason : String) : void + + cancelAppointment(date : String, time : String) : void + + viewFullSchedule() : void + + dailySummary(date : String) : void + + + addedToWaitingList(patient : Patient) : void + + viewWaitList() : void } -class YourNameClinicApp { + +class ClinicApp { + main(args : String[]) : void } @@ -49,22 +68,23 @@ class YourNameClinicApp { ' RELATIONSHIPS EXPLAINED ' ========================================= -' One Patient has zero or many Appointments. -' "1" means one Patient. -' "0..*" means that Patient can have zero or many Appointment objects. -' *-- means composition (Appointments belong to the Patient and cannot exist without it). -YourNamePatient "1" *-- "0..*" YourNameAppointment - - ' One ClinicSystem manages zero or many Patients. ' "1" means one ClinicSystem. ' "0..*" means the system can manage zero or many Patient objects. ' o-- means aggregation (Patients can exist independently of the ClinicSystem). -YourNameClinicSystem "1" o-- "0..*" YourNamePatient +ClinicSystem "1" o-- "0..*" Patient + + +' One ClinicSystem manages zero or many Appointments. +' "1" means one ClinicSystem. +' "0..*" means the system can manage zero or many Appointment objects. +' o-- means aggregation (Appointments can exist independently of the ClinicSystem). +ClinicSystem "1" o-- "0..*" Appointment ' ClinicApp depends on ClinicSystem. ' This means the main application class uses ClinicSystem to run the program. ' --> represents a dependency relationship. -YourNameClinicApp --> YourNameClinicSystem -@enduml \ No newline at end of file +ClinicApp --> ClinicSystem + +@enduml diff --git a/src/main/java/org/codedifferently/BryantClinicApp.java b/src/main/java/org/codedifferently/BryantClinicApp.java index 9e32634..1b5ced5 100644 --- a/src/main/java/org/codedifferently/BryantClinicApp.java +++ b/src/main/java/org/codedifferently/BryantClinicApp.java @@ -1,4 +1,146 @@ package org.codedifferently; +import java.util.Scanner; + public class BryantClinicApp { -} + + public static void main(String[] args) { + + Scanner input = new Scanner(System.in); //Scanner object called input + BryantClinicSystem clinic = new BryantClinicSystem(); //instance of the BryantClinicSystem class called clinic + int choice; + + do { + displayClinicMenu(); + try { + choice = input.nextInt(); + input.nextLine(); + } catch (Exception e) { + System.out.println("Invalid input. Please enter a number from the menu."); + input.nextLine(); // clear bad input + choice = -1; // force default case + } + + //Actions based on the menu number the user selects + switch (choice) { + case 1: + System.out.print("Enter patient's species: "); + String species = input.nextLine(); + System.out.print("Enter patient's name: "); + String name = input.nextLine(); + System.out.print("Enter owner's phone number(no dashes): "); + String phone = input.nextLine(); + KennyPatient newPatient = new KennyPatient(species, name, false, phone); + clinic.addPatient(newPatient); + break; + + case 2: + clinic.viewAllPatients(); + break; + + case 3: + System.out.print("Enter patient ID to check in: "); + String checkInId = input.nextLine(); + KennyPatient patient = clinic.getPatientById(Integer.parseInt(checkInId)); + if (patient != null) { + clinic.checkInPatient(patient); + clinic.lookUpPatientById(Integer.parseInt(checkInId)); + } else { + System.out.println("Patient not found."); + System.out.println("---------------------------"); + } + break; + + case 4: + System.out.print("Enter patient ID: "); + String id = input.nextLine(); + clinic.lookUpPatientById(Integer.parseInt(id)); + break; + + case 5: + System.out.print("Enter patient's name: "); + name = input.nextLine(); + System.out.println("Enter the owner's phone number (no dashes): "); + phone = input.nextLine(); + clinic.lookUpPatient(name,phone); + break; + + case 6: + System.out.print("Enter the date of your appointment (MM/DD/YYYY): "); + String date = input.nextLine(); + System.out.print("Enter the time you want to schedule the appointment: "); + String time = input.nextLine().toUpperCase(); + System.out.print("Enter the reason for scheduling this appointment: "); + String reason = input.nextLine(); + System.out.println("Enter the patient's id: "); + String patientID = input.nextLine(); + clinic.scheduleAppointment(Integer.parseInt(patientID), date, time, reason); + break; + + case 7: + System.out.print("Enter the date of your appointment (MM/DD/YYYY): "); + String cancelDate = input.nextLine(); + System.out.print("Enter the time of your appointment: "); + String cancelTime = input.nextLine().toUpperCase(); + clinic.cancelAppointment(cancelDate, cancelTime); + break; + + case 8: + clinic.viewFullSchedule(); + break; + + case 9: + System.out.print("Enter date for summary (MM/DD/YYYY): "); + String summaryDate = input.nextLine(); + + clinic.dailySummary(summaryDate); + break; + + case 10: + clinic.viewWaitList(); + break; + + case 11: + System.out.print("Enter patient's species: "); + species = input.nextLine(); + System.out.print("Enter patient's name: "); + name = input.nextLine(); + System.out.print("Enter owner's phone number(no dashes): "); + phone = input.nextLine(); + KennyPatient newPatient2 = new KennyPatient(species, name, false, phone); + clinic.addedToWaitingList(newPatient2); + break; + + case 0: + System.out.println("Exiting system. Goodbye!"); + break; + + default: + System.out.println("Invalid choice. Please try again."); + } + + } while (choice != 0); + + input.close(); + } + + //helper function to display the menu options + public static void displayClinicMenu(){ + System.out.println("\n**** Welcome to the Community Clinic System! ****"); + System.out.println("Please select an option:"); + System.out.println("1. Add New Patient"); + System.out.println("2. View All Patients"); + System.out.println("3. Check In Patient"); + System.out.println("4. Search Patient by ID"); + System.out.println("5. Search Patient by Name and Phone Number"); + System.out.println("6. Schedule Appointment"); + System.out.println("7. Cancel Appointment"); + System.out.println("8. View Full Schedule"); + System.out.println("9. Daily Summary Report"); + System.out.println("10. View Waitlist"); + System.out.println("11. Add Patient to Waitlist"); + System.out.println("0. Exit"); + System.out.println(); + System.out.print("Enter choice: "); + } +}// ends class diff --git a/src/main/java/org/codedifferently/BryantClinicSystem.java b/src/main/java/org/codedifferently/BryantClinicSystem.java index ec15b00..e4e9838 100644 --- a/src/main/java/org/codedifferently/BryantClinicSystem.java +++ b/src/main/java/org/codedifferently/BryantClinicSystem.java @@ -3,12 +3,13 @@ import java.util.ArrayList; public class BryantClinicSystem { - + //instance variables private ArrayList patients; private ArrayList waitingList; private ArrayList appointments; private String[] dailyTimeSlots = {"9:00AM", "10:00AM", "11:00AM", "1:00PM", "2:00PM", "3:00PM"}; + //constructor public BryantClinicSystem() { this.patients = new ArrayList<>(); @@ -22,12 +23,13 @@ public BryantClinicSystem() { patients.add(p2); // Preloaded appointments - MesheikAppointment a1 = new MesheikAppointment("12/10/2026", "9:00AM", "Checkup"); - MesheikAppointment a2 = new MesheikAppointment("12/10/2026", "10:00AM", "Vaccination"); + MesheikAppointment a1 = new MesheikAppointment("12/10/2026", "9:00AM", "Checkup", p1); + MesheikAppointment a2 = new MesheikAppointment("12/10/2026", "10:00AM", "Vaccination", p2); appointments.add(a1); appointments.add(a2); } + //checks to see if the time is in the time slot array public boolean isValidTime(String time) { for (String slot : dailyTimeSlots) { if (slot.equalsIgnoreCase(time)) { @@ -37,16 +39,21 @@ public boolean isValidTime(String time) { return false; } - public void scheduleAppointment(String date, String time, String reason) { + //adds the appointment to the appointment array + public void scheduleAppointment(int patientId, String date, String time, String reason) { + + // Find the patient first + KennyPatient patient = getPatientById(patientId); + // checks for bad input if (date == null || date.isEmpty() || time == null || time.isEmpty() || - reason == null || reason.isEmpty()) { + reason == null || reason.isEmpty()){ System.out.println("Invalid input. All fields are required to schedule an appointment."); return; } - // Validate time exists in daily schedule + // Validate if time exists in daily schedule if (!isValidTime(time)) { System.out.println("Invalid time slot."); return; @@ -61,11 +68,13 @@ public void scheduleAppointment(String date, String time, String reason) { } // If the appointment is valid and not booked, schedule the appointment - MesheikAppointment newAppointment = new MesheikAppointment(date, time, reason); + MesheikAppointment newAppointment = new MesheikAppointment(date, time, reason, patient); appointments.add(newAppointment); System.out.println("Appointment scheduled successfully."); } + + //displays all the appointments public void viewFullSchedule() { if (appointments.isEmpty()) { System.out.println("No appointments are scheduled."); @@ -80,74 +89,95 @@ public void viewFullSchedule() { } } + //removes an appointment from the list of appointments public void cancelAppointment(String date, String time) { for (int i = 0; i < appointments.size(); i++) { MesheikAppointment appointment = appointments.get(i); if (appointment.getDate().equals(date) && appointment.getTime().equalsIgnoreCase(time)) { if (appointment.isCompleted()) { System.out.println("Cannot cancel a completed appointment."); + System.out.println("---------------------------"); return; } appointments.remove(i); System.out.println("The Appointment was cancelled."); + System.out.println("---------------------------"); return; } } System.out.println("Appointment not found."); + System.out.println("---------------------------"); } + //marks an appointment as complete when the appointment is completed public void completeAppointment(String date, String time) { for (MesheikAppointment appointment : appointments) { if (appointment.getDate().equals(date) && appointment.getTime().equalsIgnoreCase(time)) { if (appointment.isCompleted()) { System.out.println("Appointment already completed."); + System.out.println("---------------------------"); return; } appointment.markCompleted(); System.out.println("Appointment marked as completed."); + System.out.println("---------------------------"); return; } } System.out.println("Appointment not found."); + System.out.println("---------------------------"); } + //adds patients to the waiting list public void addedToWaitingList(KennyPatient patient) { waitingList.add(patient); - System.out.println("Patient added to waiting list."); + System.out.println(patient.getName() + " has been added to the waitlist."); + System.out.println("---------------------------"); } + //displays the waiting list public void viewWaitList() { if (waitingList.isEmpty()) { System.out.println("Waitlist is empty."); + System.out.println("---------------------------"); return; } - System.out.println("---- Waiting List ----"); + System.out.println("***** Waiting List *****"); for (KennyPatient patient : waitingList) { patient.displayInfo(); } + System.out.println("---------------------------"); } - + //adds the patient to the list of patients public void addPatient(KennyPatient patient){ patients.add(patient); + System.out.println("Patient added successfully."); + System.out.println("---------------------------"); } + //displays all paitents public void viewAllPatients(){ for (KennyPatient patient : patients) { patient.displayInfo(); } } + //searches for a patient by their name and phone number public void lookUpPatient(String name, String phoneNumber){ for (KennyPatient patient : patients) { if (name.equals(patient.getName()) && phoneNumber.equals(patient.getOwnersPhoneNumber())) { patient.displayInfo(); + return; } } + System.out.println("Patient not found."); + System.out.println("---------------------------"); } + //searches for a patient by their ID number public void lookUpPatientById(int id){ for (KennyPatient patient : patients) { if (patient.getPatientId() == id) { @@ -156,18 +186,34 @@ public void lookUpPatientById(int id){ } } System.out.println("Patient not found."); + System.out.println("---------------------------"); } + //returns a patient object by the ID the user passes in + public KennyPatient getPatientById(int id) { + for (KennyPatient patient : patients) { + if (patient.getPatientId() == id) { + return patient; + } + } + return null; + } + + + //checks the patient in for their appointment public void checkInPatient(KennyPatient patient) { if (patient.isCheckedIn()) { System.out.println("Patient already checked in."); + System.out.println("---------------------------"); return; } patient.setCheckedIn(true); System.out.println("Patient checked in successfully."); + System.out.println("---------------------------"); } + //displays the statuses of all the appointments public void dailySummary(String date) { int total=0, completed=0, pending=0; @@ -183,10 +229,11 @@ public void dailySummary(String date) { } } - System.out.println("----- Daily Summary for " + date + " -----"); + System.out.println("***** Daily Summary for " + date + "*****"); System.out.println("Total Appointments: " + total); System.out.println("Completed Appointments: " + completed); System.out.println("Pending Appointments: " + pending); + System.out.println("---------------------------"); } }// ends class diff --git a/src/main/java/org/codedifferently/KennyPatient.java b/src/main/java/org/codedifferently/KennyPatient.java index c774bd6..95b5a79 100644 --- a/src/main/java/org/codedifferently/KennyPatient.java +++ b/src/main/java/org/codedifferently/KennyPatient.java @@ -4,6 +4,7 @@ public class KennyPatient { + //instance variables for the patient class private String species; private String name; @@ -13,8 +14,10 @@ public class KennyPatient { private String ownersPhoneNumber; private int patientId; - private int idCounter = 1; + private static int idCounter = 1; + + //constructor public KennyPatient(String species, String name, boolean checkedIn, String ownersPhoneNumber) { this.species = species; @@ -27,6 +30,7 @@ public KennyPatient(String species, String name, boolean checkedIn, String owner this.patientId = idCounter++; } + //getter methods for the instance variables public String getSpecies() { return species; } @@ -45,13 +49,15 @@ public int getPatientId() { public String getOwnersPhoneNumber(){return ownersPhoneNumber;} + //getter methods for the instance variables public void setCheckedIn(Boolean checkedIn) { - this.checkedIn = checkedIn; - } + this.checkedIn = checkedIn; + } public void setName(String name) { this.name = name; } + public void setOwnersPhoneNumber(String ownersPhoneNumber){ this.ownersPhoneNumber = ownersPhoneNumber; } @@ -60,6 +66,7 @@ public void setSpecies(String species){ this.species = species; } + //displays the information of a single patient public void displayInfo() { System.out.println("Patient ID: " + patientId); System.out.println("Pet Name: " + name); diff --git a/src/main/java/org/codedifferently/MesheikAppointment.java b/src/main/java/org/codedifferently/MesheikAppointment.java index ae79b1f..6562b6d 100644 --- a/src/main/java/org/codedifferently/MesheikAppointment.java +++ b/src/main/java/org/codedifferently/MesheikAppointment.java @@ -8,13 +8,17 @@ public class MesheikAppointment { private String time; private String reason; private boolean completed; + private KennyPatient patient; + + // Constructor runs when an appointment is created - public MesheikAppointment(String date, String time, String reason){ + public MesheikAppointment(String date, String time, String reason ,KennyPatient patient){ this.date = date; this.time = time; this.reason = reason; this.completed = false; + this.patient = patient; } //Getters: how we get our appointments From b735f1f09ddb6e905beb0df7d956e5acb04087b5 Mon Sep 17 00:00:00 2001 From: Bryant Ferguson Date: Mon, 23 Feb 2026 12:25:55 -0500 Subject: [PATCH 17/17] Added a case to mark an appointment as completed --- .../java/org/codedifferently/BryantClinicApp.java | 12 ++++++++++++ src/main/java/org/codedifferently/KennyPatient.java | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codedifferently/BryantClinicApp.java b/src/main/java/org/codedifferently/BryantClinicApp.java index 1b5ced5..7484ef3 100644 --- a/src/main/java/org/codedifferently/BryantClinicApp.java +++ b/src/main/java/org/codedifferently/BryantClinicApp.java @@ -45,6 +45,7 @@ public static void main(String[] args) { if (patient != null) { clinic.checkInPatient(patient); clinic.lookUpPatientById(Integer.parseInt(checkInId)); + } else { System.out.println("Patient not found."); System.out.println("---------------------------"); @@ -111,6 +112,16 @@ public static void main(String[] args) { clinic.addedToWaitingList(newPatient2); break; + case 12: + System.out.print("Enter appointment date (MM/DD/YYYY): "); + String compDate = input.nextLine(); + + System.out.print("Enter appointment time: "); + String compTime = input.nextLine().toUpperCase(); + + clinic.completeAppointment(compDate, compTime); + break; + case 0: System.out.println("Exiting system. Goodbye!"); break; @@ -139,6 +150,7 @@ public static void displayClinicMenu(){ System.out.println("9. Daily Summary Report"); System.out.println("10. View Waitlist"); System.out.println("11. Add Patient to Waitlist"); + System.out.println("12. Mark an Appointment as Completed"); System.out.println("0. Exit"); System.out.println(); System.out.print("Enter choice: "); diff --git a/src/main/java/org/codedifferently/KennyPatient.java b/src/main/java/org/codedifferently/KennyPatient.java index 95b5a79..befb4b0 100644 --- a/src/main/java/org/codedifferently/KennyPatient.java +++ b/src/main/java/org/codedifferently/KennyPatient.java @@ -74,6 +74,4 @@ public void displayInfo() { System.out.println("Owner's Phone Number: " + ownersPhoneNumber); System.out.println("Checked In: " + checkedIn); System.out.println("---------------------------"); } - - }