A Java-based console application that enables patients to book medical appointments, while admins manage doctors using advanced Java features like OOP, annotations, reflection, and custom exception handling — all without file handling to keep the focus on core Java principles.
- 👤 User Types: Abstract
Userclass with two main roles:Patient,Doctor, andAdmin - 🗓️ Appointment Booking: Patients can book appointments with available doctors
- ✅ Appointment Completion: Mark appointments as completed, which re-enables the doctor
- 🔐 Admin Role Security: Role-based access using custom annotations and reflection
⚠️ Robust Error Handling: Custom exceptionInvalidAppointmentExceptionfor booking/management errors- 💡 No File Handling: Focus entirely on OOP, Java Collections, Reflection, Annotations, and Exception Handling
- Fields:
id,name - Abstract method:
void showProfile()
- Field:
boolean available = true - Getter/setter & overrides
showProfile()
- Overrides
showProfile()
- Fields:
PatientDoctorString status = "Scheduled"
- Constructor sets doctor as unavailable
- Method
completeAppointment()sets status to"Completed"and re-enables the doctor - Provides
getStatus()andappointmentDetails()
- Thrown if:
- No doctors are available
- Appointment index is invalid or already completed
- Retention:
RUNTIME - Target:
TYPE - Used to secure admin-only actions via reflection
- Annotated with
@Security(role = "Admin") - Method:
removeDoctor(List<Doctor> doctors, String doctorId)validated via reflection
- Fields:
List<Patient> patientsList<Doctor> doctorsList<Appointment> appointments
- Methods:
registerPatient(Patient patient)registerDoctor(Doctor doctor)Appointment bookAppointment(Patient patient)void completeAppointment(int index)void showAllDoctors()void showAllAppointments()
- Interactive Menu:
1. Register Patient2. Register Doctor3. Book Appointment4. Show All Doctors5. Show All Appointments6. Complete Appointment7. Exit