P6.1: Hospital D n ny gip Sinh vin Hiu c gi v phm vi truy cp. /* * Doctor.
java * * This class is used store details about a doctor. * * Copyright 2009 - [Link] */ package hospital; import [Link]; public class Doctor { /** Instance variable to store unique doctor code. */ int code; /** Instance variable to store doctor name. */ String name; /** Instance variable to store the address of the doctor. */ String address; /** Instance variable to store phone number of the doctor. */ String phone; /** Creates a new instance of Doctor */ public Doctor() { code = 0; name = ""; address = ""; phone = ""; } /** * Method to display the doctor information. */ void getDoctorInfo() { [Link]("The details about the doctor are:"); [Link]("Code: " + code); [Link]("Address: " + address); [Link]("Phone Number: " + phone);
} /** * Method to accept the details about a doctor. */ void setDoctorInfo() { Scanner input = new Scanner([Link]); // Use the Enter key (new line character) as the delimiter [Link]("\n"); [Link]("Enter [Link]("Enter code = [Link](); [Link]("Enter name = [Link](); [Link]("Enter address = [Link](); [Link]("Enter phone = [Link](); } } /* * [Link] * * This class is used store details about a patient. * * Copyright 2009 - [Link] */ package hospital; import [Link].*; public class Patient { /** * Instance variable to store unique patient code. */ int code; /** * Instance variable to store name of the patient. */ String name; details about the doctor:"); doctor's code:"); name:"); address:"); phone number:");
/** * Instance variable to store age of the patient. */ int age; /** * Instance variable to store address of the patient. */ String address; /** * Instance variable to store illness symptoms. */ String symptoms; /** * Instance variable to store code of the * doctor assigned to the patient. */ int doctorCode; /** * Instance variable to store name of the * doctor assigned to the patient. */ String doctorName; /** * Class variable to store the percentage of discount. */ /** * Creates a new instance of Patient. */ public Patient() { code = 0; name = ""; address = ""; doctorCode = 0; doctorName = ""; } /** * Method to display the details of Patient.
*/ void getPatientDetails() { [Link]("The details about the patient are:"); [Link]("Code: " + code); [Link]("Age: " + age); [Link]("Address: " + address); [Link]("Symptoms: " + symptoms); } /** * Method to accept the details of Patient. */ void setPatientDetails() { Scanner input = new Scanner([Link]); [Link]("\n"); [Link]("Enter [Link]("Enter code = [Link](); [Link]("Enter name = [Link](); [Link]("Enter age = [Link](); [Link]("Enter address = [Link](); details about the patient:"); patient code:" ); name:"); age:" ); address:");
[Link]("Enter Symptoms: You can type as many lines as " + "you wish. Enter 0 to stop."); // Accept the details about various symptoms until the user types a zero symptoms = new Scanner([Link]).useDelimiter("0").next(); } } /* * [Link] * * This program is designed to demonstrate the use of classes Doctor and Patient * defined in the same package. * * Copyright 2009 - [Link] */ package info; import [Link]; import [Link];
public class Admin { /** * This is the entry point of the application. * @param args the command line arguments */ public static void main(String[] args) { // Create a new Doctor Doctor objDoctor = new Doctor(); // Accept details about the doctor [Link](); // Create a new Patient Patient objPatient = new Patient(); // Accept patient details [Link](); // Assign a doctor to a patient [Link] = [Link]; [Link] = [Link]; [Link]("The doctor for %s is %s.", [Link], [Link]); [Link](); // Display the patient and doctor details [Link](); [Link](); } }