The assignment for my Application Development class has us creating an office sy
ID: 3603005 • Letter: T
Question
The assignment for my Application Development class has us creating an office system for a dentist. The following requirements are:
It must display the current lists for Dentists, Assistants, Patients, and Services
It must allow the user to add/edit/or delete items from this list
It must display an invoice for the customer based on the chosen services
My main question revolves around the add/edit/delete portion of the assignment. I'd like to know which method would be best to do this. He did however give use the guideline that we should not use a database.
Below is what I have so far. Note: I don't need the code for all four lists, if I have one, I should be able to figure out the others.
import java.util.Scanner;
import java.util.ArrayList;
public class OfficeSystem
{
public static void main (String[] args)
{
Scanner sc = new Scanner (System.in);
System.out.println("***************************************************************");
System.out.println(" Kennesaw Dental Office ");
System.out.println("***************************************************************");
System.out.println("1. Display Patient List");
System.out.println("2. Display Doctor List");
System.out.println("3. Display Assistant List");
System.out.println("4. Display Service Fees");
System.out.println("5. Edit Patient List");
System.out.println("6. Edit Doctor List");
System.out.println("7. Edit Assistant List");
System.out.println("8. Edit Service Fees");
System.out.println("9. Issue Patient Invoice");
System.out.println("0. Exit the Program");
System.out.println("Please select an option: ");
int option = sc.nextInt();
switch(option)
{
case 1:
System.out.println("***************************************************************************");
System.out.println(" Patients ");
System.out.println("***************************************************************************");
break;
case 2:
System.out.println("***************************************************************************");
System.out.println(" Doctors ");
System.out.println("***************************************************************************");
break;
case 3:
System.out.println("***************************************************************************");
System.out.println(" Assistants ");
System.out.println("***************************************************************************");
break;
case 4:
System.out.println("***************************************************************************");
System.out.println(" Service Fees ");
System.out.println("***************************************************************************");
break;
case 5:
System.out.println("***************************************************************************");
System.out.println(" Patients ");
System.out.println("***************************************************************************");
System.out.println("Please enter an option 1-4");
System.out.println("1. Add a new entry");
System.out.println("2. Edit an existing entry");
System.out.println("3. Delete an entry");
System.out.println("4. Return to main menu");
int option = sc.nextInt();
switch(option)
{
}
case 6:
System.out.println("***************************************************************************");
System.out.println(" Doctors ");
System.out.println("***************************************************************************");
System.out.println("Please enter an option 1-4");
System.out.println("1. Add a new entry");
System.out.println("2. Edit an existing entry");
System.out.println("3. Delete an entry");
System.out.println("4. Return to main menu");
int option = sc.nextInt();
switch(option)
{
}
case 7:
System.out.println("***************************************************************************");
System.out.println(" Assistants ");
System.out.println("***************************************************************************");
System.out.println("Please enter an option 1-4");
System.out.println("1. Add a new entry");
System.out.println("2. Edit an existing entry");
System.out.println("3. Delete an entry");
System.out.println("4. Return to main menu");
int option = sc.nextInt();
switch(option)
{
}
case 8:
System.out.println("***************************************************************************");
System.out.println(" Service Fees ");
System.out.println("***************************************************************************");
System.out.println("Please enter an option 1-4");
System.out.println("1. Add a new entry");
System.out.println("2. Edit an existing entry");
System.out.println("3. Delete an entry");
System.out.println("4. Return to main menu");
int option = sc.nextInt();
switch(option)
{
}
}
}
}
Explanation / Answer
You may define classes for Doctor , Assistant , Service, Patient. Patient will include an String ArrayList to hold the services choosen. Add relevant attributes for each of the classes. In the main program.. create arraylist for each of the classes some thing like
ArrayList<Doctor> doctors = new ArrayList<Doctor>();
ArrayList<Patient> patients = new ArrayList<Patient>();
ArrayList<Assistant> doctors = new ArrayList<Assistant>();
ArrayList<Service> services = new ArrayList<Service>();
Then when ever you have Add option selected, add the appropriate object (after user inputs the details) into its correpsonding list. Write findDoctor(ArrayList<Doctor> doctors, String name) to return index of a specified doctor name. Similarly you can do findPatient() , findService(). When the search name is not found, these find methods should return -1. The findXXXX() methods will be useful when you want to edit/delete an entry. For example , when edit option is used for doctor, use findDoctor(ArrayList<Doctor> doctors , String name) to get the index of the Doctor object. Ask the user for new details and set it on the object using setter methods. If the doctor is not found (index = -1), print approrpriate message. Similarly if delete option is used , first get the index of the object and then use remove(index) on the corresponding list. You will need to do this for each of Doctor, Patient, Service objects.
Hope this gave you some idea and how to go about coding for this assignment.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.