/************************************************************************* * Compilation: javac HI.java * Execution: java HI year < _HI.txt * * % java HI 2004 < _HI.txt * * *************************************************************************/ public class HI { public static void main(String[] args) { // year of election int year = Integer.parseInt(args[0]); // scale coordinates and set window size double xmin = -160.555771; double xmax = -154.809372; double ymin = 18.913826; double ymax = 22.23601; StdDraw.setCanvasSize(1013, 800); StdDraw.setXscale(xmin, xmax); StdDraw.setYscale(ymin, ymax); // process data while (!StdIn.isEmpty()) { String name = StdIn.readLine(); String usps = StdIn.readLine(); int N = StdIn.readInt(); Point[] points = new Point[N]; for (int i = 0; i < N; i++) { double x = StdIn.readDouble(); double y = StdIn.readDouble(); points[i] = new Point(x, y); } Polygon poly = new Polygon(points); Region region = new Region(name, usps, poly); // VoteTally votes = new VoteTally(name, usps, year); StdDraw.setPenColor(StdDraw.BLACK); region.fill(); StdDraw.setPenColor(StdDraw.WHITE); region.draw(); // ignore empty line StdIn.readLine(); StdIn.readLine(); } } }