/* * Point.java * Copyright 2013 Thomas Reinhardt * */ import java.util.Scanner; // using .nextDouble() and maybe others. /** * Objects of class Point represent 2-D points in a Cartesian Plane. */ public class Point { // useful when we re-cast this class as a dynamic object private double x_pos; private double y_pos; // in any event, we make this object in "class scope" to // make it visible to every method within this class! private static Scanner myScanner = new Scanner( System.in ); // ____ properties. // Main entry: public static void main (String args[]) { System.out.println("Enter a value for this point's x pos: "); // ... // call the distance formula and print the result. } // Public Interface: /** * use the standard distance formula here, which is the square root * of the sum of the differences between components. In 2-D space, * that means the square root of the sum of the differences between * the ordinate (x) and coordinate (y) values for this Point. * (Note, this method will use Math.pow( double, double )). */ public static double distance( double x1, double y1, double x2, double y2 ) { return 0.0; } /* Notice how awkward that last method appears ... we need to * provide a lot of information ourselves that is included in * any reasonable object called Point. Eventually, we will * replace that with a dynamic method whose signature appears * below. Notice that the public static version might then * become "private" and might then be called from within the * body of its replacement: */ public double distance( Point otherPoint ) { return 0.0; } // Private Helper methods. // use private helper functions (methods) to simplify the task of // computing distances between Points: private static double x_difference( double p1_x, double p2_x ) { return 0.0; } private static double y_difference( double p1_y, double p2_y ) { return 0.0; } }