From bc477506342411e9156b3230d847cb92bcb8e5f9 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 24 Nov 2015 11:11:17 +0100 Subject: Reformat code --- src/ch/epfl/maze/util/Action.java | 8 +------- src/ch/epfl/maze/util/Direction.java | 12 +----------- src/ch/epfl/maze/util/LabyrinthGenerator.java | 21 +-------------------- src/ch/epfl/maze/util/Statistics.java | 8 +------- src/ch/epfl/maze/util/Vector2D.java | 16 +--------------- 5 files changed, 5 insertions(+), 60 deletions(-) (limited to 'src/ch/epfl/maze/util') diff --git a/src/ch/epfl/maze/util/Action.java b/src/ch/epfl/maze/util/Action.java index 25509a4..069f135 100644 --- a/src/ch/epfl/maze/util/Action.java +++ b/src/ch/epfl/maze/util/Action.java @@ -5,7 +5,6 @@ package ch.epfl.maze.util; * about it, such as if it was successful or not, and if the animal will die * while performing it. */ - public final class Action { /* variables defining the action */ @@ -19,7 +18,6 @@ public final class Action { * * @param dir Direction towards which the action needs to be performed */ - public Action(Direction dir) { if (dir != null) { mDirection = dir; @@ -37,7 +35,6 @@ public final class Action { * @param dir Direction towards which the action needs to be performed * @param successful Determines whether this action was successful */ - public Action(Direction dir, boolean successful) { mDirection = dir; mSuccess = successful; @@ -53,7 +50,6 @@ public final class Action { * @param successful Determines whether this action was successful * @param dies Determines whether the action will die between two squares */ - public Action(Direction dir, boolean successful, boolean dies) { mDirection = dir; mSuccess = successful; @@ -65,7 +61,6 @@ public final class Action { * * @return Direction of the action */ - public Direction getDirection() { return mDirection; } @@ -75,7 +70,6 @@ public final class Action { * * @return true if the action was successful, false otherwise */ - public boolean isSuccessful() { return mSuccess; } @@ -87,8 +81,8 @@ public final class Action { * @return true if the action dies between two squares, false * otherwise */ - public boolean diesBetweenSquares() { return mDies; } + } diff --git a/src/ch/epfl/maze/util/Direction.java b/src/ch/epfl/maze/util/Direction.java index 5f83c22..d2ee4e7 100644 --- a/src/ch/epfl/maze/util/Direction.java +++ b/src/ch/epfl/maze/util/Direction.java @@ -7,14 +7,12 @@ package ch.epfl.maze.util; * * @author Pacien TRAN-GIRARD */ - public enum Direction { DOWN, UP, RIGHT, LEFT, NONE; /** * An array of all the possible directions that can be taken. */ - public static final Direction[] POSSIBLE_DIRECTIONS = new Direction[]{ Direction.DOWN, Direction.UP, @@ -27,7 +25,6 @@ public enum Direction { * * @return Integer value of the direction */ - public int intValue() { switch (this) { case DOWN: @@ -53,7 +50,6 @@ public enum Direction { * * @return Orthonormal {@code Vector2D} that represents the direction. */ - public Vector2D toVector() { switch (this) { case DOWN: @@ -79,7 +75,6 @@ public enum Direction { * * @return The opposite direction. */ - public Direction reverse() { switch (this) { case DOWN: @@ -107,7 +102,6 @@ public enum Direction { * @return true if the direction is the opposite the argument, * false otherwise */ - public boolean isOpposite(Direction d) { return this == d.reverse(); } @@ -120,7 +114,6 @@ public enum Direction { * @return The direction converted to the frame of reference given by the * direction called. */ - public Direction relativeDirection(Direction dir) { switch (this) { case DOWN: @@ -148,7 +141,6 @@ public enum Direction { * @return The direction converted back to the frame of reference of the * labyrinth */ - public Direction unRelativeDirection(Direction dir) { switch (this) { case DOWN: @@ -174,7 +166,6 @@ public enum Direction { * * @return The rotated direction to the right */ - public Direction rotateRight() { switch (this) { case DOWN: @@ -200,7 +191,6 @@ public enum Direction { * * @return The rotated direction to the left */ - public Direction rotateLeft() { switch (this) { case DOWN: @@ -230,7 +220,6 @@ public enum Direction { * @return The directions converted to the frame of reference given by the * direction which calls the method */ - public Direction[] relativeDirections(Direction[] dir) { Direction[] relativeDirections = new Direction[dir.length]; @@ -240,4 +229,5 @@ public enum Direction { return relativeDirections; } + } diff --git a/src/ch/epfl/maze/util/LabyrinthGenerator.java b/src/ch/epfl/maze/util/LabyrinthGenerator.java index 3e83ec5..9e47c25 100644 --- a/src/ch/epfl/maze/util/LabyrinthGenerator.java +++ b/src/ch/epfl/maze/util/LabyrinthGenerator.java @@ -10,7 +10,6 @@ import java.util.regex.Pattern; /** * Generates a set of pre-computed labyrinth structures */ - public final class LabyrinthGenerator { /** @@ -18,7 +17,6 @@ public final class LabyrinthGenerator { * * @return A small labyrinth */ - public static int[][] getSmall() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1}, @@ -42,7 +40,6 @@ public final class LabyrinthGenerator { * * @return A medium labyrinth */ - public static int[][] getMedium() { int[][] labyrinth = { {1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, @@ -106,7 +103,6 @@ public final class LabyrinthGenerator { * * @return The Pac-Man level */ - public static int[][] getPacMan() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, @@ -142,7 +138,6 @@ public final class LabyrinthGenerator { * * @return One of the Ms. Pac-Man levels */ - public static int[][] getMsPacMan() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, @@ -179,7 +174,6 @@ public final class LabyrinthGenerator { * * @return A labyrinth multiply connected */ - public static int[][] getMultiplyConnected() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,}, @@ -205,7 +199,6 @@ public final class LabyrinthGenerator { * * @return A maze for debugging the Mouse */ - public static int[][] getDebugMouse() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1}, @@ -225,7 +218,6 @@ public final class LabyrinthGenerator { * * @return A maze for debugging the Hamster */ - public static int[][] getDebugHamster() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, @@ -245,7 +237,6 @@ public final class LabyrinthGenerator { * * @return A maze for debugging the Monkey */ - public static int[][] getDebugMonkey() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, @@ -266,7 +257,6 @@ public final class LabyrinthGenerator { * * @return A maze for debugging the Bear */ - public static int[][] getDebugBear1() { int[][] labyrinth = { {1, 1, 1, 2, 1, 1, 1,}, @@ -286,7 +276,6 @@ public final class LabyrinthGenerator { * * @return A maze for debugging the Bear */ - public static int[][] getDebugBear2() { int[][] labyrinth = { {1, 2, 1, 1}, @@ -305,7 +294,6 @@ public final class LabyrinthGenerator { * * @return A maze for debugging the Panda */ - public static int[][] getDebugPanda1() { int[][] labyrinth = { {1, 1, 1, 2, 1, 1, 1}, @@ -324,7 +312,6 @@ public final class LabyrinthGenerator { * * @return A maze for debugging the Panda */ - public static int[][] getDebugPanda2() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1, 1, 1}, @@ -349,7 +336,6 @@ public final class LabyrinthGenerator { * * @return A maze to run with a Bear and a Monkey */ - public static int[][] getBearVsMonkey() { int[][] labyrinth = { {1, 1, 1, 3, 1, 1, 1}, @@ -368,7 +354,6 @@ public final class LabyrinthGenerator { * * @return A maze to run with a Panda and a Hamster */ - public static int[][] getPandaVsHamster() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, @@ -394,7 +379,6 @@ public final class LabyrinthGenerator { * * @return A maze for debugging Blinky */ - public static int[][] getDebugBlinky() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1, 1}, @@ -414,7 +398,6 @@ public final class LabyrinthGenerator { * * @return A maze for debugging Pinky */ - public static int[][] getDebugPinky() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1, 1, 1}, @@ -432,7 +415,6 @@ public final class LabyrinthGenerator { * * @return A maze for debugging Inky */ - public static int[][] getDebugInky() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, @@ -456,7 +438,6 @@ public final class LabyrinthGenerator { * * @return A maze for debugging Clyde */ - public static int[][] getDebugClyde() { int[][] labyrinth = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1,}, @@ -479,7 +460,6 @@ public final class LabyrinthGenerator { * @param filename The file location * @return Labyrinth structure parsed from a file */ - public static int[][] readFromFile(String filename) { File file = new File(filename); int[][] labyrinth = null; @@ -528,4 +508,5 @@ public final class LabyrinthGenerator { return labyrinth; } + } diff --git a/src/ch/epfl/maze/util/Statistics.java b/src/ch/epfl/maze/util/Statistics.java index ae16392..3928859 100644 --- a/src/ch/epfl/maze/util/Statistics.java +++ b/src/ch/epfl/maze/util/Statistics.java @@ -8,7 +8,6 @@ import java.util.*; /** * Utility class that allows to compute statistics on a list of results. */ - public final class Statistics { /* constants for the length of the distribution axis */ @@ -21,7 +20,6 @@ public final class Statistics { * @param results List of numbers * @return The total of the list */ - public static int total(List results) { int total = 0; for (Integer result : results) { @@ -41,7 +39,6 @@ public final class Statistics { * @param results List of numbers * @return The mean of the results */ - public static int mean(List results) { int total = total(results); if (total == Integer.MAX_VALUE) { @@ -58,7 +55,6 @@ public final class Statistics { * @param results List of numbers * @return The variance of the results */ - public static double var(List results) { double mean = mean(results); if (mean == Integer.MAX_VALUE) { @@ -79,7 +75,6 @@ public final class Statistics { * @param results List of numbers * @return The variance of the results */ - public static double std(List results) { return Math.sqrt(var(results)); } @@ -90,7 +85,6 @@ public final class Statistics { * @param simulation Simulation to make statistics on * @param numberOfSimulations The number of simulations */ - public static Map> computeStatistics( Simulation simulation, int numberOfSimulations) { // maps animals' names with their overall results (which are linked-list) @@ -128,7 +122,6 @@ public final class Statistics { * * @param results List of numbers */ - public static void printDistribution(List results) { int min = results.get(0); @@ -181,4 +174,5 @@ public final class Statistics { } System.out.println(">"); } + } diff --git a/src/ch/epfl/maze/util/Vector2D.java b/src/ch/epfl/maze/util/Vector2D.java index 407851c..52e1e55 100644 --- a/src/ch/epfl/maze/util/Vector2D.java +++ b/src/ch/epfl/maze/util/Vector2D.java @@ -3,7 +3,6 @@ package ch.epfl.maze.util; /** * Immutable 2-dimensional vector (x, y). */ - public final class Vector2D { /* shift constant to compute the hash */ @@ -20,7 +19,6 @@ public final class Vector2D { * @param x Horizontal coordinate * @param y Vertical coordinate */ - public Vector2D(int x, int y) { mX = x; mY = y; @@ -40,7 +38,6 @@ public final class Vector2D { * @param y Vertical coordinate to add * @return The result of an addition with two coordinates */ - public Vector2D add(int x, int y) { return new Vector2D(mX + x, mY + y); } @@ -51,7 +48,6 @@ public final class Vector2D { * @param v Vector to add * @return The result of the addition with the vector */ - public Vector2D add(Vector2D v) { return add(v.mX, v.mY); } @@ -63,7 +59,6 @@ public final class Vector2D { * @param y Vertical coordinate to subtract * @return The result of the subtraction with the vector */ - public Vector2D sub(int x, int y) { return new Vector2D(mX - x, mY - y); } @@ -74,7 +69,6 @@ public final class Vector2D { * @param v Vector to subtract * @return The result of the subtraction with the vector */ - public Vector2D sub(Vector2D v) { return sub(v.mX, v.mY); } @@ -84,7 +78,6 @@ public final class Vector2D { * * @return The negated version of the vector */ - public Vector2D negate() { return new Vector2D(-mX, -mY); } @@ -95,7 +88,6 @@ public final class Vector2D { * @param scalar Number to multiply the coordinates with * @return The result of the multiplication with a scalar */ - public Vector2D mul(int scalar) { return new Vector2D(scalar * mX, scalar * mY); } @@ -106,7 +98,6 @@ public final class Vector2D { * @param scalar Number to divide the coordinates with * @return The result of the division with a scalar */ - public Vector2D div(int scalar) { return new Vector2D(scalar / mX, scalar / mY); } @@ -116,7 +107,6 @@ public final class Vector2D { * * @return The normalized version of the vector */ - public Vector2D normalize() { double dist = dist(); return new Vector2D((int) (mX / dist), (int) (mY / dist)); @@ -127,7 +117,6 @@ public final class Vector2D { * * @return The length of the vector */ - public double dist() { return Math.sqrt(mX * mX + mY * mY); } @@ -138,7 +127,6 @@ public final class Vector2D { * @param d Direction to add * @return The result of the addition with the direction */ - public Vector2D addDirectionTo(Direction d) { switch (d) { case UP: @@ -164,7 +152,6 @@ public final class Vector2D { * * @return The closest direction corresponding to the vector */ - public Direction toDirection() { Vector2D normal = this.normalize(); @@ -186,7 +173,6 @@ public final class Vector2D { * * @return x-coordinate of the vector */ - public int getX() { return mX; } @@ -196,7 +182,6 @@ public final class Vector2D { * * @return y-coordinate of the vector */ - public int getY() { return mY; } @@ -222,4 +207,5 @@ public final class Vector2D { return o.hashCode() == this.hashCode(); } + } -- cgit v1.2.3