Methods and fields may or may not be accessible in subclasses, depending on their access modifiers.
class Rectangle { private Point origin, corner; /* make sure origin is left top and corner of right bottom */ public Rectangle(Point org, Point cor) { if (org.x <= cor.x) if (org.y <= cor.y) { origin = new Point(org.x, org.y); corner = new Point(cor.x, cor.y); } else { origin = new Point(org.x, cor.y); corner = new Point(cor.x, org.y); } else if (org.y <= cor.y) { origin = new Point(cor.x, org.y); corner = new Point(org.x, cor.y); } else { origin = new Point(cor.x, cor.y); corner = new Point(org.x, org.y); } } }