Doctor/Clinic.java
Doctor/Clinic.java
/* Created by IntelliJ IDEA.
* Author: Kshitij Varshney (kshitijvarshne1)
* Date: 29-Apr-21
* Time: 6:18 PM
* File: Clinic.java
*/
package April.api29_21;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
public class Clinic {
List doctorList = new ArrayList<>();
List petList = new ArrayList<>();
public static void main(String[] args) {
Clinic c = new Clinic();
c.run();
}
private void run() {
while (true) {
showOptions();
int k = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter the option menu", "Input Window", JOptionPane.PLAIN_MESSAGE));
switch (k) {
case 1 -> {
JTextField name = new JTextField();
JTextField specialisation = new JTextField();
Object[] input = {
"Enter doctor name:", name,
"Enter doctor specialisation", specialisation
};
JOptionPane.showConfirmDialog(null, input, "Input ", JOptionPane.OK_CANCEL_OPTION);
boolean result = addDoctor(name.getText(), specialisation.getText());
if (result) {
JOptionPane.showMessageDialog(null, "New Doctor is inserted", "Message", JOptionPane.PLAIN_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, "New Doctor is not inserted", "Message", JOptionPane.ERROR_MESSAGE);
}
}
case 2 -> {
JTextField petName = new JTextField();
JTextField type = new JTextField();
JTextField size = new JTextField();
JTextField weight = new JTextField();
JTextField age = new JTextField();
JTextField doctorName = new JTextField();
Object[] input2 = {
"Enter pet name:", petName,
"Enter pet type", type,
"Enter pet size:", size,
"Enter pet weight", weight,
"Enter pet age:", age,
"Enter doctor name :", doctorName
};
JOptionPane.showConfirmDialog(null, input2, "Input ", JOptionPane.OK_CANCEL_OPTION);
boolean result2 = addPet(petName.getText(), type.getText(), size.getText(), Integer.parseInt(weight.getText()), Integer.parseInt(age.getText()), doctorName.getText());
if (result2) {
JOptionPane.showMessageDialog(null, "New pet is inserted", "Message", JOptionPane.PLAIN_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, "New pet is not inserted", "Message", JOptionPane.ERROR_MESSAGE);
}
}
case 3 -> {
String name3 = JOptionPane.showInputDialog(null, "Enter the doctor name", "Input", JOptionPane.PLAIN_MESSAGE);
boolean result3 = deleteDoctor(name3);
if (result3) {
JOptionPane.showMessageDialog(null, " Doctor is deleted", "Message", JOptionPane.PLAIN_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, " Doctor is not deleted", "Message", JOptionPane.ERROR_MESSAGE);
}
}
case 4 -> {
String name4 = JOptionPane.showInputDialog(null, "Enter the pet name", "Input", JOptionPane.PLAIN_MESSAGE);
boolean result4 = deletePet(name4);
if (result4) {
JOptionPane.showMessageDialog(null, " pet is deleted", "Message", JOptionPane.PLAIN_MESSAGE);
} else {
JOptionPane.showMessageDialog(null, " pet is not deleted", "Message", JOptionPane.ERROR_MESSAGE);
}
}
case 5 -> showListOfDoctors();
case 6 -> showListOfPets();
case 7 -> {
String name5 = JOptionPane.showInputDialog(null, "Enter the doctor name", "Input", JOptionPane.PLAIN_MESSAGE);
listOfPetsAssignedToASpecificDoctor(name5);
}
case 8 -> {
JTextField doctor = new JTextField();
JTextField pet = new JTextField();
Object[] input3 = {
"Enter doctor name:", doctor,
"Enter pet name: ", pet
};
JOptionPane.showConfirmDialog(null, input3, "Input ", JOptionPane.OK_CANCEL_OPTION);
assignedADoctorToPet(doctor.getText(), pet.ge...