update the constructor to fit the new requirements
[aco.git] / AntMain.java
blobccf962b41ae9b578135bc362b8ced32e88887894
1 import java.io.IOException;
3 class AntMain {
5 public static void main(String[] args) {
6 try {
8 Graph graph;
9 Environment env;
10 int iterations = 0, guisize = 0;
12 try {
13 iterations = Integer.parseInt(args[0]);
14 } catch (Exception e) {
15 System.exit(1);
18 if (args.length == 2) {
19 try {
20 guisize = Integer.parseInt(args[1]);
21 } catch (Exception e) { }
23 if (guisize == 0) {
24 graph = new Graph(args[1]);
25 } else {
26 graph = Graph.sampleGraph();
28 env = new Environment(iterations, graph);
30 env.run();
31 System.out.println(env);
32 } else if (args.length == 3) {
34 guisize = Integer.parseInt(args[1]);
35 graph = new Graph(args[2]);
36 env = new Environment(iterations, guisize, graph);
38 env.run();
39 System.out.println(env);
40 } else {
41 System.exit(1);
44 /* wait for a keypress before exit */
45 System.in.read();
47 } catch (IOException e) {
48 System.out.println(e.toString() + "(" + e.getClass() + "): " + e);
51 System.exit(0);