aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/fr/umlv/java/wallj/Main.java18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/Main.java b/src/main/java/fr/umlv/java/wallj/Main.java
index 3b3ad54..0ac4136 100644
--- a/src/main/java/fr/umlv/java/wallj/Main.java
+++ b/src/main/java/fr/umlv/java/wallj/Main.java
@@ -2,6 +2,7 @@ package fr.umlv.java.wallj;
2 2
3import fr.umlv.java.wallj.board.Board; 3import fr.umlv.java.wallj.board.Board;
4import fr.umlv.java.wallj.board.BoardParser; 4import fr.umlv.java.wallj.board.BoardParser;
5import fr.umlv.java.wallj.board.BoardValidator;
5import fr.umlv.java.wallj.viewer.Viewer; 6import fr.umlv.java.wallj.viewer.Viewer;
6import fr.umlv.zen5.Application; 7import fr.umlv.zen5.Application;
7 8
@@ -32,20 +33,31 @@ public class Main {
32 } 33 }
33 34
34 public static void main(String[] args) { 35 public static void main(String[] args) {
35 java.util.List<Board> boards = new LinkedList<>(); 36 List<Board> boards = new LinkedList<>();
36 try { 37 try {
37 List<Path> boardPaths = Main.getResourcePaths(args); 38 List<Path> boardPaths = Main.getResourcePaths(args);
38 for (Path path : boardPaths) { 39 for (Path path : boardPaths) {
39 boards.add(BoardParser.parse(path)); 40 BoardValidator boardValidator = new BoardValidator(BoardParser.parse(path));
41 boards.add(
42 boardValidator.validate(BoardValidator.Constraint::hasActualReachableBlocks, "Some supposed reachable blocks are not reachable.")
43 .validate(BoardValidator.Constraint::hasMandatoryBlocks, "Some mandatory blocks are missing.")
44 .validate(BoardValidator.Constraint::isBounded, "The board is not correctly bounded.")
45 .validate(BoardValidator.Constraint::isHollow, "The board must have a unique and simple interior.")
46 .get());
40 } 47 }
41 Viewer viewer = new Viewer(boards); 48 Viewer viewer = new Viewer(boards);
42 Application.run(Color.BLACK, viewer::eventLoop); 49 Application.run(Color.WHITE, viewer::eventLoop);
43 } catch (URISyntaxException e) { 50 } catch (URISyntaxException e) {
44 System.err.println(e.getMessage()); 51 System.err.println(e.getMessage());
45 System.exit(1); 52 System.exit(1);
46 } catch (IOException e) { 53 } catch (IOException e) {
47 System.err.println(e.getMessage()); 54 System.err.println(e.getMessage());
48 System.exit(2); 55 System.exit(2);
56 } catch (BoardValidator.ValidationException e) {
57 for (Throwable throwable : e.getSuppressed()) {
58 System.err.println(throwable.getMessage());
59 }
60 System.exit(3);
49 } 61 }
50 } 62 }
51} 63}