FileDocCategorySizeDatePackage
MessagePassing.javaAPI DocExample1932Wed Oct 24 16:38:32 BST 2001myprojects.messagepassing

MessagePassing.java

/*
 * @(#)MessagePassing.java 1.0 01/10/24
 *
 * You can modify the template of this file in the
 * directory ..\JCreator\Templates\Template_1\Project_Name.java
 *
 * You can also create your own project template by making a new
 * folder in the directory ..\JCreator\Template\. Use the other
 * templates as examples.
 *
 */
package myprojects.messagepassing;

import java.awt.*;
import java.awt.event.*;

class MessagePassing extends Frame {
	private Consultant c1 = new Consultant();
	private Patient p1 = new Patient();
	
	public MessagePassing() {
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				dispose();
				System.exit(0);
			}
		});
		
		
		c1.setName("Mr Important Person");
		p1.setName("Mr Joe Bloggs");
		c1.setPatient(p1);
		p1.setConsultant(c1);
		c1.displayDetails();
		p1.displayDetails();
	}

	public static void main(String args[]) {
		System.out.println("Starting MessagePassing...");
		MessagePassing mainFrame = new MessagePassing();
		mainFrame.setSize(400, 400);
		mainFrame.setTitle("MessagePassing");
		mainFrame.setVisible(true);
	}
	
}

class Consultant {
	private Patient p;
	private String name;
	
	public void setPatient(Patient pIn) {
		p = pIn;
	}
	public void setName(String nameIn) {
		name = nameIn;
	}
	public String getName() {
		return name;
	}
	public void displayDetails() {
		System.out.println("Name of consultant is " + name);
		System.out.println("Name of patient is "+ p.getName());
	}
	
}
class  Patient {
	private Consultant c;
	private String name;
	public void setConsultant(Consultant cIn) {
		c = cIn;
	}
	public void setName(String nameIn) {
		name=nameIn;
	}
	public String getName(){
		return name;
	}
	public void displayDetails() {
		System.out.println("Name of patient is " + name);
		System.out.println("Name of Consultant is "+c.getName());
	}
}