So i'm working on a program, which brings up a menu; this is the full question:
I have started the program and have 4 classes, (an extra People class because I needed to practice the Inheritance):Red Cross clinic requires a new computerized system to keep track of patients appointments and doctors records. Currently appointment information consists of patient name, patient surname, ID, Contact number, doctor, appointment date and time, and whether the patient is insured or not. Information between doctors should include their ID, name, surname, contact no, medical reg no and their specialisation. The application to be developed needs to be able to perform the following functions.
1. Book a new appointment
2. Cancel an existing appointment
3. Change date for an appointment
4. Add a new doctor
5. Delete a doctor record
6. Print all appointments for a particular doctor.
7. Exit
You are to develop this application using Console and any necessary classes and methods.
Main: (Red Cross)
import java.io.*; import java.util.*; import javax.swing.*; class RedCrossExample { public static ArrayList<Patients> appointmentsList = new ArrayList<Patients>(); public static ArrayList<Doctor> DoctList = new ArrayList<Doctor>(); public static void main(String args[]) { int option= 0; while (option !=5) { Scanner input = new Scanner(System.in); System.out.println("1.Book a new appointment"); System.out.println("2. Cancel an existing appointment"); System.out.println("3. Change date for an appointment"); System.out.println("4.Add a new doctor"); System.out.println("5. Delete a doctor record"); System.out.println("6.Print all appointments for a particular doctor"); System.out.println("7. Exit"); option = input.nextInt(); switch (option) { case 1: { BookApp(); break; } case 2: { break; } case 3: { break; } case 4: { AddDoctor(); break; } case 5: { break; } case 6: { break; } } } } public static void BookApp() { Patients patient = new Patients(); Scanner scanner1 = new Scanner(System.in); System.out.println("Name: "); patient.setName(scanner1.next()); System.out.println("Surname: "); patient.setSurname(scanner1.next()); System.out.println("Doctor: "); patient.setDoctor(scanner1.next()); System.out.println("Insurance: "); patient.setinsurance(scanner1.nextLine()); System.out.println("Appointment Day : "); int day = scanner1.nextInt(); System.out.println("Appointment Month: "); int month = scanner1.nextInt(); System.out.println("Appointment Year: "); int year = scanner1.nextInt(); System.out.println("Appointment Hour: "); int hour = scanner1.nextInt(); System.out.println("Appointment Min: "); int min = scanner1.nextInt(); Calendar app = Calendar.getInstance(); app.set(year, month, day, hour, min); patient.setAppointment(app); } public static void AddDoctor() { System.out.println("Name: "); doctor.setName(scanner2.next()); System.out.println("Surname: "); doctor.setSurname(scanner2.next()); System.out.println("ID: "); doctor.setID(scanner2.next()); System.out.println("Contact: "); doctor.setContact(scanner2.nextLine()); System.out.println("Medical Registration: "); doctor.setRegistation(scanner2.nextLine()) System.out.println("Specialization "); doctor.setSpecialization(scanner2.nextLine()) } }
Persons(for Inheritance):
import java.io.*; import java.util.*; import javax.swing.*; class Persons { public class Person { protected String id; protected String name; protected String surname; protected long contact; } public void setName(String name) { this.name = name; } public String getName(){ return name; } public void setSurname(String surname) { this.surname = surname; } public String getSurname(){ return surname; } public void setID(String id) { this.id = id; } public String getID(){ return id; } public void setContact(long contact) { this.contact = contact; } public long getContact(){ return contact; } public Persons { //empty constructor } public Persons(String Name, String Surname, String ID, long contacts) { this.name = Name; this.surname = Surname; this.id = ID; this.contact = contacs; } public String DisplayDetails() { string details =" "; details= "ID: "+this.ID+"Name: "+this.name+"Surname: "+this.surname+"Contact: "+this.contact; return details; } }
Patients:
import java.io.*; import java.util.*; import javax.swing.*; class Patients { public class patient extends Persons { private String doctor; private boolean insurance; private Calendar appointment = Calendar.getInstance(); } public void setDoctor(String doctor) { this.doctor = doctor; } public String getDoctor(){ return doctor; } public void setInsurance(boolean insurance) { this.insurance = insurance; } public boolean getInsurance() { return insurance; } public void setAppointment(Calendar appointment) { this.appointment = appointment; } public Calendar getAppointment() { return appointment; } public Patients { //empty constructor } public Patients(String Doctor, bool Insurance, Calendar AppDate) { this.doctor = Doctor; this.insurance = Insurance; this.appointment = AppDate; } public void ChangeAppDate(int day, int month, int year, int hour, int min) { Calendar changedAppointment = Calendar.getInstance(); changedAppointment.set(year, month, day, hour, min); this.appointment = changedAppointment; } public void DisplayAppDetails() { String Appdetails ="Patient : "+this.name+" "+this.surname+"\nDoctor : "+this.doctor+"\n Appointment Date : " +(day+"/"+month+"/"+year+" - "+min+":"+hour)+"/nInsurance"+insurance); } @Override public String DisplayDetails() { String details = super.DisplayDetails(); details = details+"Doctor: "+this.doctor+"Insurance: "+this.insurance+"Appointment: "+this.appointment); } }
Doctors:
import java.io.*; import java.util.*; import javax.swing.*; class Patients { public class patient extends Persons { private String doctor; private boolean insurance; private Calendar appointment = Calendar.getInstance(); } public void setDoctor(String doctor) { this.doctor = doctor; } public String getDoctor(){ return doctor; } public void setInsurance(boolean insurance) { this.insurance = insurance; } public boolean getInsurance() { return insurance; } public void setAppointment(Calendar appointment) { this.appointment = appointment; } public Calendar getAppointment() { return appointment; } public Patients { //empty constructor } public Patients(String Doctor, bool Insurance, Calendar AppDate) { this.doctor = Doctor; this.insurance = Insurance; this.appointment = AppDate; } public void ChangeAppDate(int day, int month, int year, int hour, int min) { Calendar changedAppointment = Calendar.getInstance(); changedAppointment.set(year, month, day, hour, min); this.appointment = changedAppointment; } public void DisplayAppDetails() { String Appdetails ="Patient : "+this.name+" "+this.surname+"\nDoctor : "+this.doctor+"\n Appointment Date : " +(day+"/"+month+"/"+year+" - "+min+":"+hour)+"/nInsurance"+insurance); } @Override public String DisplayDetails() { String details = super.DisplayDetails(); details = details+"Doctor: "+this.doctor+"Insurance: "+this.insurance+"Appointment: "+this.appointment); } }
EXTRA INFO: I would like the errors to be solved please, I know that the menu has only 2 options done by now, but I'll work on that later on.
Thanks ya'll <3