FileDocCategorySizeDatePackage
CompareObjects.javaAPI DocExample1235Sun Oct 28 12:40:18 GMT 2001myprojects.compareobjects

CompareObjects.java

/*
 * @(#)CompareObjects.java 1.0 01/10/27
 *
 * 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.compareobjects;

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

class CompareObjects extends Frame{
	
	public CompareObjects() {
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				dispose();
				System.exit(0);
			}
		});
	}

	public static void main(String args[]) {
		System.out.println("Starting CompareObjects...");
		Room r1 = new Room();
		Room r2 = new Room();
		
		String s1;
		String s2;
		s1 = new String("Hello world");
		s2 = s1;
		System.out.println(s2);
		if(s1 == s2) System.out.println("s1 and s2 refer to the same object");
		
		
		// set up a room of 4 by 3 metres
		r1.setSize(4.0, 3.0);
		r2.setSize(2.0, 6.0);
		if(r1.compareSize(r2)) {
			System.out.println("Rooms r1 and r2 the same size");
		} else {
			System.out.println("Rooms r1 and r2 not the same size");
		}
	
		
	}
}