/*
* Hospital.java 1.0 01/10/19
*
*/
package myprojects.hospital;
import java.awt.*;
import java.awt.event.*;
class Hospital extends Frame {
private Patient p1 = new Patient();
private InPatient ip2 = new InPatient();
public Hospital() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
});
// Set the details for an InPatient
ip2.setInPatientDetails("Fred Smith", 70, "wm123c", 0, "Otter Ward");
// Set the details for an OutPatient
p1.setPatientDetails("June Smith", 66 , "AB1234D");
}
public void paint(Graphics g) {
// Invoke the display details methods here
p1.displayPatientDetails(g,20,60);
ip2.displayInPatientDetails(g,20,160);
// Increment the number of days resident
// (this is a devious way of finding out how many times the
// paint method is invoked)...
ip2.incrementDaysResident();
}
public static void main(String args[]) {
System.out.println("Starting Hospital...");
Hospital mainFrame = new Hospital();
mainFrame.setSize(400, 400);
mainFrame.setTitle("Hospital");
mainFrame.setVisible(true);
}
}
|