// File: Main.java
// Time-stamp: "2005-09-21 23:47:30 calvanese"
// Purpose: Written exam 20/9/2005 - BSc in Computer Science (6CFU)
//          Main program for testing the solution

import java.io.*;

public class Main {

  public static Polygon readPolygon(String filename)
                                        throws IOException, PolygonException {
    FileReader f = new FileReader(filename);
    BufferedReader br = new BufferedReader(f);

    Polygon pol = new Polygon(10);
    int count = 0;
    Vertex v = Vertex.readVertex(br);
    while (v != null) {
      pol.addVertex(v, 0);
      v = Vertex.readVertex(br);
      count++;
    }

    f.close(); // or equivalently br.close();
    return pol;
  }


  public static void main (String[] args) throws IOException, PolygonException {
    
    Polygon pol = readPolygon("vertices.txt");

    ClientPolygon.coordinatesOfColor(pol, "red", "vertices-red.txt");
    ClientPolygon.coordinatesOfColor(pol, "blue", "vertices-blue.txt");
    ClientPolygon.coordinatesOfColor(pol, "green", "vertices-green.txt");
    ClientPolygon.coordinatesOfColor(pol, "white", "vertices-white.txt");
  }
}
