// Earl Bergquist, Garfield High School
// Demonstrates usage of Math methods and Scanner

import java.util.*;
import java.awt.*;

public class MathScannerTrial {
	public static void main(String[] args) {
		// Demonstrate a call of our calculateDistance Method
		calculateDistance(10, 15, 30, 10);
				
		// Create the Scanner Object, s
		Scanner s = new Scanner(System.in);
		// Create the Drawing Panel Object, p
		DrawingPanel p = new DrawingPanel(200, 200);
		// Create the Graphics Object, g
		Graphics g = p.getGraphics();
		
		// Take in 3 pairs of coordinates to Graph and Calculate distance
		for(int i = 0; i < 3; i++) {
			distanceCalculator(s, g);
		}
		
	}
	
	// Given x and y coordinates for two points, calculate length of line segment connecting them
	public static void calculateDistance(int x1, int y1, int x2, int y2) {
		double distance = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
		System.out.println("Distance between (" + x1 + ", " + y1 + ") and (" + x2 + ", " + y2 + "): " + distance);
	}
	
	// Prompts the user for two points, plots them and calculates the distance between them
	public static void distanceCalculator(Scanner s, Graphics g) {
		System.out.print("Your first point (enter x and y, less than 200): ");
		int x1 = s.nextInt();
		int y1 = s.nextInt();
		System.out.print("Your second point (enter x and y, less than 200): ");
		int x2 = s.nextInt();
		int y2 = s.nextInt();
		
		g.drawLine(x1, y1, x2, y2);
		calculateDistance(x1, y1, x2, y2);	
	}
}
