// This class is a client of the Point1 class, that // is, it creates Point1 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 PointClient1 { public static void main(String[] args) { // Separate variables are poor style because // the related information is only tied together // by being named similarly. //int p1x = 5; //int p1y = 10; //int p2x = 3; //int p2y = -8; // Saving points in 2-element arrays is poor // style since people can make int[]'s of any // length and I'd have to check to make sure // they were length 2 before I used them. //int[] p1 = {5, 10}; //int[] p2 = {3, -8}; // Instead I create my own Point1 class that has // a place for an x and a y for each point Point1 p1 = new Point1(); p1.x = 5; //set p1's x value to 5 p1.y = 10; //set p1's y value to 10 Point1 p2 = new Point1(); p2.x = 3;//set p2's x value to 3 p2.y = -8;//set p2's y value to -8 // print out p1 System.out.println("p1 = " + p1.x + ", " + p1.y); // print out p2 System.out.println("p2 = " + p2.x + ", " + p2.y); } }