1  public class CreateObjectDemo {
 2    public static void main(String[] args) {
 3
 4      // create a point object and two rectangle objects
 5      Point origin_one = new Point(23, 94);
 6      Rectangle rect_one = new Rectangle(origin_one, 100, 200);
 7      Rectangle rect_two = new Rectangle(50, 100);
 8
 9      // display rect_one's width, height, and area
10      System.out.println("Width of rect_one: " + rect_one.width);
11      System.out.println("Height of rect_one: " + rect_one.height);
12      System.out.println("Area of rect_one: " + rect_one.area());
13
14      // set rect_two's position
15      rect_two.origin = origin_one;
16
17      // display rect_two's position
18      System.out.println("X Position of rect_two: " + rect_two.origin.x);
19      System.out.println("Y Position of rect_two: " + rect_two.origin.y);
20
21      // move rect_two and display its new position
22      rect_two.move(40, 72);
23      System.out.println("X Position of rect_two: " + rect_two.origin.x);
24      System.out.println("Y Position of rect_two: " + rect_two.origin.y);
25    }
26  }

Generated with vim2html
Copyright © 2003-2004 by Chip Cuccio <http://norlug.org/~chipster/finger>