// This class is a client of the PositivePoint class, that // is, it creates PositivePoint objects and uses them. // // Java can run this file as a program since it has // a public static void main(String[] args) method. public class PositivePointClient { public static void main(String[] args) { PositivePoint p1 = new PositivePoint(5, 10); //Note: PositivePoint fixes the -8 value I send it PositivePoint p2 = new PositivePoint(3, -8); // I can't run the following line since the field y // is private. //p2.y = -8; System.out.println("p1 = " + p1); System.out.println("p2 = " + p2); // The Point objects know how to handle translate() themselves, // so we ask them to do it. // Note: the translate method fixes the negative x // value from the translate on p1. p1.translate(-10, 3); p2.translate(4, 8); System.out.println("Distance of p1 = " + p1.distanceFromOrigin()); System.out.println("Distance of p2 = " + p2.distanceFromOrigin()); System.out.println(); System.out.println("p1 = " + p1); System.out.println("p2 = " + p2); } }