Point.java
Select all
/* Point.java CIS 260 2005-02-09 David Klick This is a demonstration of a class that will be included within another class (composition). */ public class Point extends Object { int x, y; public Point() { setLocation(0,0); } public Point(int x, int y) { setLocation(x,y); } public Point(Point p) { setLocation(p.x,p.y); } public boolean equals(Point p) { return p.x==x && p.y==y; } public Point getLocation() { return new Point(x,y); } public int getX() { return x; } public int getY() { return y; } public String toString() { return "(" + x + "," + y + ")"; } public void setLocation(int x, int y) { this.x = x; this.y = y; } }