import java.util.Date; import java.awt.*; //=================================== Lab1 =============================== // // Input: n the number of points // // Output: A pair of closest points and their distance // //======================================================================== public class Lab1 { //================================ main =============================== // // You can use command line arguments to have the output and/or input // come from a file versus the command line. // // If there are two arguments then the first one is the file from where // the input is read and the second is the file where a transcript is // saved. // // If there is just one argument then it is the file where a transcript // is saved. public static void main(String args[]){ if (args.length == 2) { Terminal.readInputFromFile(args[0]); Terminal.startTranscript(args[1]); } else if (args.length == 1) { Terminal.startTranscript(args[0]); } // If you don't know how to use command line arguments and want to // save a transcript in a file called "myTranscript.txt" you can // uncomment out the following line (and change the filename to // whatever you want). // // Terminal.startTranscript("myTranscript.txt"); // If you would like the points to be read from "sample-pointfile" then // you can replace the code below through the call to generateRandomPoints by // // XYPoint points[] = PointReader.readXYPoints("sample-pointfile"); Terminal.println("How many points? "); int n = Terminal.readInt(); // Use this line if you want a different random set of points each time the // program is run. However, for your submitted output you are required to // use 3.14 * n as the seed as it is currently done. // // java.util.Random randseq = new java.util.Random(); java.util.Random randseq = new java.util.Random((long) 3.14 * n); XYPoint points[] = generateRandomPoints(n,randseq); Date startTime = new Date(); //start clock since data is created // Call ClosestPair algorithm here -- feel free to change the class or method // name to match what you use. PointPair closest = ClosestPair.closestPair(points); Date endTime = new Date(); //stop clock since closest pair computed if (points.length <= 50){ Terminal.println("The points are:"); for (int i=0; i