diff --git a/maptools/pom.xml b/maptools/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..4cc7306a1514e7506526db6356b6764f20b14e07 --- /dev/null +++ b/maptools/pom.xml @@ -0,0 +1,78 @@ + + + 4.0.0 + + robot-modules + fr.ufrst.m1info.gl.tparineymates + 1.0-SNAPSHOT + + + fr.ufrst.m1info.gl.tparineymates + maptools + 1.0-SNAPSHOT + + maptools + + http://www.example.com + + + UTF-8 + 1.7 + 1.7 + + + + + junit + junit + 4.11 + test + + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + + + diff --git a/maptools/src/main/java/fr/ufrst/m1info/gl/tparineymates/Coordinates.java b/maptools/src/main/java/fr/ufrst/m1info/gl/tparineymates/Coordinates.java new file mode 100644 index 0000000000000000000000000000000000000000..f866599580f2468a6d8d37f334f8c49886fd7be7 --- /dev/null +++ b/maptools/src/main/java/fr/ufrst/m1info/gl/tparineymates/Coordinates.java @@ -0,0 +1,20 @@ +package fr.ufrst.m1info.gl.tparineymates; + +public class Coordinates { + + private int x; + private int y; + + public Coordinates(int x, int y) { + this.x = x; + this.y = y; + } + + public int getX() { + return x; + } + + public int getY() { + return y; + } +} diff --git a/maptools/src/main/java/fr/ufrst/m1info/gl/tparineymates/Direction.java b/maptools/src/main/java/fr/ufrst/m1info/gl/tparineymates/Direction.java new file mode 100644 index 0000000000000000000000000000000000000000..c72f0d26733bd04abc166cdd86f76cf7c7644580 --- /dev/null +++ b/maptools/src/main/java/fr/ufrst/m1info/gl/tparineymates/Direction.java @@ -0,0 +1,5 @@ +package fr.ufrst.m1info.gl.tparineymates; + +public enum Direction { + NORTH, WEST, SOUTH, EAST +} diff --git a/maptools/src/main/java/fr/ufrst/m1info/gl/tparineymates/MapTools.java b/maptools/src/main/java/fr/ufrst/m1info/gl/tparineymates/MapTools.java new file mode 100644 index 0000000000000000000000000000000000000000..acd93bfa030cd26915725212d33a44df0fa4dff8 --- /dev/null +++ b/maptools/src/main/java/fr/ufrst/m1info/gl/tparineymates/MapTools.java @@ -0,0 +1,38 @@ +package fr.ufrst.m1info.gl.tparineymates; + +public class MapTools { + + static Coordinates nextForwardPosition(Coordinates position, Direction direction) { + if (direction == Direction.NORTH) + return new Coordinates(position.getX(), position.getY() + 1); + if (direction == Direction.SOUTH) + return new Coordinates(position.getX(), position.getY() - 1); + if (direction == Direction.EAST) + return new Coordinates(position.getX() + 1, position.getY()); + return new Coordinates(position.getX() - 1, position.getY()); + } + + static Coordinates nextBackwardPosition(Coordinates position, Direction direction) { + if (direction == Direction.NORTH) + return new Coordinates(position.getX(), position.getY() - 1); + if (direction == Direction.SOUTH) + return new Coordinates(position.getX(), position.getY() + 1); + if (direction == Direction.EAST) + return new Coordinates(position.getX() - 1, position.getY()); + return new Coordinates(position.getX() + 1, position.getY()); + } + + static Direction counterclockwise(Direction direction) { + if (direction == Direction.NORTH) return Direction.WEST; + if (direction == Direction.WEST) return Direction.SOUTH; + if (direction == Direction.SOUTH) return Direction.EAST; + return Direction.NORTH; + } + + static Direction clockwise(Direction direction) { + if (direction == Direction.NORTH) return Direction.EAST; + if (direction == Direction.EAST) return Direction.SOUTH; + if (direction == Direction.SOUTH) return Direction.WEST; + return Direction.NORTH; + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 3fe96875ecbef473cf4ef9c056619827f625feaf..db921089e42adfbbf56fdc11281eebf717557a87 100644 --- a/pom.xml +++ b/pom.xml @@ -17,5 +17,6 @@ robot battery + maptools