diff --git a/src/Map.java b/src/Map.java index 0822ff2..7e8a6f9 100644 --- a/src/Map.java +++ b/src/Map.java @@ -1,19 +1,47 @@ import java.awt.Point; +import java.util.ArrayList; -public class Map { +public class Map +{ private Circuit[][] map; - private Point[] pathMap; + private ArrayList pathMap; - public Map(Circuit[][] map) { + public Map(Circuit[][] map) + { this.map = map; - this.buildPath(); } - private boolean buildPath() { - return false; + private Point[] bindPath() + { + Point start = null; + Point end = null; + + for (int i = 0; i < map.length; i++) + { + for (int j = 0; j < map.length; j++) + { + switch (map[i][j].getType()) + { + case CircuitCell.START: + if (start == null) start = new Point(i, j); + else return null; + break; + case CircuitCell.FINISH: + if (end == null) end = new Point(i, j); + else return null; + break; + default: + break; + } + } + } + + return new Point[] {start, end}; } - public Circuit getElement(int x, int y) { + + public Circuit getElement(int x, int y) + { return map[y][x]; } }