/*
 * Created on Jan 23, 2005
 *
 * Advanced Data Management Group
 * Center for Advanced Computing and Informatics Studies
 * University of Puerto Rico, Mayaguez
 * 
 */
package edu.uprm.admg.point;

import java.io.*;

/**
 * @author Manuel Rodriguez
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class PointTester {

	private void test_loop(BufferedReader in) throws IOException{
		String reps = null;
		int i, len = 0;
		Point P = new Point();
		
		System.out.println("Enter a positive integer: ");
		reps = in.readLine();
		len = Integer.parseInt(reps);
		
		for(i = 0; i < len; ++i){
			P.setX(i);
			P.setY(i+1);
			System.out.println(P.toString());
		}
	}
	
	public void start() throws Exception {
		Point P1 = new Point();

		System.out.println("Setting a point P1 = (2,3) ");
	    P1.setX(2);
	    P1.setY(3);
	    System.out.println(P1.toString());
	    
	    System.out.println("Creating Point P2 = (-4, 5) ");
	    Point P2 = new Point(-4,5);
	    System.out.println(P2.toString());
	    
	    System.out.print("Printing the distance to origin  from P1: ");
	    System.out.println(P1.distanceOrigin());

	    System.out.println("Computing distance between P1 and P2");
	    double dist = P1.distance(P2);
	    System.out.println("distance (P1,P2) = " + dist);

	    System.out.println("Computing P3 = P1 + P2 ");
	    Point P3;
	    P3 = P1.sum(P2);
	    System.out.println("P3 = " + P3.toString());
	        
	    System.out.println("Enter point P4: ");
	    Point P4 = new Point();
		BufferedReader in= 
			new BufferedReader(new InputStreamReader(System.in));
	    
	    P4.read(in);
	    System.out.println("Point P4 = " + P4.toString());
	    
	    if (P1.equals(P4)){
	    	System.out.println("Points P1 and P4 are the same.");	
	    }
	    else {
	    	System.out.println("Points P1 and P4 are different.");
	    }
	    
	    // Call Function Test Loop
	    test_loop(in);

	    System.out.println("Done!");
	    System.exit(0);
		
	}
	
	public static void main(String[] args) {
		PointTester tester = new PointTester();
		
		try {
			tester.start();
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
}
