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/graphics/Animation.java | 9 --------- src/ch/epfl/maze/graphics/Display.java | 12 +----------- src/ch/epfl/maze/graphics/GraphicComponent.java | 8 +------- src/ch/epfl/maze/main/Console.java | 5 +---- src/ch/epfl/maze/main/Program.java | 5 +---- src/ch/epfl/maze/physical/Animal.java | 7 +------ src/ch/epfl/maze/physical/GhostPredator.java | 4 ++-- src/ch/epfl/maze/physical/Maze.java | 6 +----- src/ch/epfl/maze/physical/World.java | 16 +--------------- src/ch/epfl/maze/physical/pacman/Pinky.java | 3 +-- src/ch/epfl/maze/physical/zoo/Hamster.java | 5 +---- src/ch/epfl/maze/physical/zoo/Monkey.java | 5 +---- src/ch/epfl/maze/physical/zoo/Panda.java | 2 +- src/ch/epfl/maze/physical/zoo/SpaceInvader.java | 4 +--- src/ch/epfl/maze/simulation/DaedalusSimulation.java | 6 +----- src/ch/epfl/maze/simulation/MazeSimulation.java | 4 +--- src/ch/epfl/maze/simulation/Simulation.java | 10 +--------- src/ch/epfl/maze/tests/AnimalTest.java | 7 +------ src/ch/epfl/maze/tests/Competition.java | 8 +------- src/ch/epfl/maze/tests/DaedalusTest.java | 4 +--- src/ch/epfl/maze/tests/GhostsTest.java | 8 +------- src/ch/epfl/maze/tests/MazeTest.java | 4 +--- src/ch/epfl/maze/tests/WorldTest.java | 16 +--------------- src/ch/epfl/maze/tests/ZooTest.java | 11 +---------- 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 +--------------- 29 files changed, 29 insertions(+), 205 deletions(-) (limited to 'src/ch/epfl/maze') diff --git a/src/ch/epfl/maze/graphics/Animation.java b/src/ch/epfl/maze/graphics/Animation.java index ce80c78..a00b6b2 100644 --- a/src/ch/epfl/maze/graphics/Animation.java +++ b/src/ch/epfl/maze/graphics/Animation.java @@ -22,7 +22,6 @@ import java.util.TreeMap; * * @author Pacien TRAN-GIRARD */ - public final class Animation { /** @@ -62,7 +61,6 @@ public final class Animation { * @param animals The {@code List} of animals that will be shown on the first * frame */ - public Animation(List animals) { mGraphMap = new TreeMap(); mImages = new HashMap(); @@ -94,7 +92,6 @@ public final class Animation { * @param id Unique identifier for animal * @param action Action that animal needs to perform */ - public void update(Animal animal, int id, Action action) { // sanity checks if (action == null) { @@ -123,7 +120,6 @@ public final class Animation { * * @param id Identifier of animal to kill */ - public void updateDying(int id) { GraphicComponent graphComp = mGraphMap.get(id); if (graphComp != null) { @@ -135,7 +131,6 @@ public final class Animation { * Notifies the animation that updates were done, and that it can start * animating from now. */ - public void doneUpdating() { mDone = false; } @@ -149,7 +144,6 @@ public final class Animation { * @param targetWindow The window on which the graphic components will be painted * (assumed non-null) */ - public void paint(float dt, Graphics2D g, ImageObserver targetWindow) { mRatio += dt; if (mRatio > 1) { @@ -181,7 +175,6 @@ public final class Animation { * * @return true if the animation is done, false otherwise */ - public boolean isDone() { return mDone; } @@ -192,7 +185,6 @@ public final class Animation { * number of frames will still be painted to prevent the screen from * flashing. */ - public void reset(List animals) { mGraphMap.clear(); if (animals != null) { @@ -225,7 +217,6 @@ public final class Animation { * @param animal Animal whose image needs to be loaded or returned * @return The buffered image of the animal */ - private BufferedImage loadImage(Animal animal) { // path = "img/superclass/class.png" String superClassName = animal.getClass().getSuperclass().getSimpleName(); diff --git a/src/ch/epfl/maze/graphics/Display.java b/src/ch/epfl/maze/graphics/Display.java index 2fddcf1..baacefa 100644 --- a/src/ch/epfl/maze/graphics/Display.java +++ b/src/ch/epfl/maze/graphics/Display.java @@ -17,7 +17,6 @@ import java.util.Map; /** * Handles the display of a {@code Simulation} on a window. */ - public final class Display implements Runnable { /* constants */ @@ -58,7 +57,6 @@ public final class Display implements Runnable { * * @param simulation A {@code Simulation} to display */ - public Display(Simulation simulation) { // sanity check if (simulation == null) { @@ -124,7 +122,6 @@ public final class Display implements Runnable { * * @param debug The new debug value */ - public void setDebug(boolean debug) { mDebug = debug; mShowGrid = debug; @@ -135,7 +132,6 @@ public final class Display implements Runnable { /** * Creates frame window. */ - private void createWindow() { // actual window mFrame = new JFrame("Maze solver simulation"); @@ -163,7 +159,6 @@ public final class Display implements Runnable { /** * Creates canvas. */ - private void createCanvas() { // actual canvas mCanvas = new Canvas(); @@ -183,7 +178,6 @@ public final class Display implements Runnable { /** * Creates menu. */ - private void createMenu() { // creates menu bar mMenuBar = new JMenuBar(); @@ -371,7 +365,6 @@ public final class Display implements Runnable { * * @param g The graphics on which the labyrinth will be drawn */ - private void drawLabyrinth(Graphics2D g) { World world = mSimulation.getWorld(); @@ -405,7 +398,6 @@ public final class Display implements Runnable { * @param width Width of graphics * @param height Height of graphics */ - private void drawAnimation(float dt, Graphics2D g, int width, int height) { // clears background g.setColor(BACKGROUND_COLOR); @@ -448,7 +440,6 @@ public final class Display implements Runnable { * * @param dt The elapsed time between two frames */ - private void animate(float dt) { Graphics2D g = null; try { @@ -475,7 +466,6 @@ public final class Display implements Runnable { /** * Runs the animation main loop. */ - private void mainLoop() { long before = System.nanoTime(); while (mRunning) { @@ -508,7 +498,6 @@ public final class Display implements Runnable { /** * Computes the {@code Simulation}'s next move. */ - private void nextMove() { synchronized (mLock) { if (mRunning) { @@ -516,4 +505,5 @@ public final class Display implements Runnable { } } } + } diff --git a/src/ch/epfl/maze/graphics/GraphicComponent.java b/src/ch/epfl/maze/graphics/GraphicComponent.java index e49a542..44b4b1f 100644 --- a/src/ch/epfl/maze/graphics/GraphicComponent.java +++ b/src/ch/epfl/maze/graphics/GraphicComponent.java @@ -13,7 +13,6 @@ import java.awt.image.ImageObserver; /** * Graphic component of an animal that will be drawn by an {@link Animation}. */ - public final class GraphicComponent { /* constants */ @@ -35,7 +34,6 @@ public final class GraphicComponent { * @param position Position at which the image will be drawn * @param action Action that the component needs to perform */ - public GraphicComponent(BufferedImage image, Vector2D position, Action action) { // sanity checks if (image == null) { @@ -58,7 +56,6 @@ public final class GraphicComponent { /** * Notifies the component that it will die between two squares. */ - public void willDieMoving() { mAction = new Action(mAction.getDirection(), mAction.isSuccessful(), true); } @@ -71,7 +68,6 @@ public final class GraphicComponent { * @param g Graphic environment * @param targetWindow Window on which the graphic is being drawn */ - public void paint(float ratio, Graphics2D g, ImageObserver targetWindow) { if (mAction.getDirection() == Direction.NONE) { renderStuck(g, targetWindow); @@ -98,7 +94,6 @@ public final class GraphicComponent { * @param targetWindow Frame display * @param buzz Buzzes the animal, used when he has just hit a wall */ - private void renderMove(float ratio, Graphics2D g, ImageObserver targetWindow, boolean buzz) { // transforms direction into vector Vector2D heading = mAction.getDirection().toVector().mul(SQUARE_SIZE); @@ -142,7 +137,6 @@ public final class GraphicComponent { * @param g Graphic environment * @param targetWindow Frame display */ - private void renderStuck(Graphics2D g, ImageObserver targetWindow) { // loads default frame of image with default direction BufferedImage img = cropImage(-1, Direction.NONE); @@ -176,7 +170,6 @@ public final class GraphicComponent { * @param dir The direction towards which the component faces * @return The correct frame that faces towards the direction specified */ - private BufferedImage cropImage(float ratio, Direction dir) { int width = mImage.getWidth(); int height = mImage.getHeight(); @@ -218,4 +211,5 @@ public final class GraphicComponent { return img; } + } diff --git a/src/ch/epfl/maze/main/Console.java b/src/ch/epfl/maze/main/Console.java index cbcb8dc..931bec4 100644 --- a/src/ch/epfl/maze/main/Console.java +++ b/src/ch/epfl/maze/main/Console.java @@ -22,7 +22,6 @@ import java.util.Map; * Mini-project main program that will run the simulations multiple times and * show statistics on the console. */ - public class Console { /** @@ -52,7 +51,6 @@ public class Console { * * @return A {@code MazeSimulation} suitable for statistics */ - public static Simulation getMazeSimulation() { int[][] labyrinth = LabyrinthGenerator.getMedium(); Maze m = new Maze(labyrinth); @@ -84,7 +82,6 @@ public class Console { * * @return A {@code DaedalusSimulation} suitable for statistics */ - public static Simulation getDaedalusSimulation() { int[][] labyrinth = LabyrinthGenerator.getPacMan(); Daedalus d = new Daedalus(labyrinth); @@ -113,7 +110,6 @@ public class Console { * * @param results Statistics of arrival times for every animals/preys */ - public static void printStats(Map> results) { // computes statistics for (Map.Entry> entry : results.entrySet()) { @@ -154,4 +150,5 @@ public class Console { Statistics.printDistribution(list); } } + } diff --git a/src/ch/epfl/maze/main/Program.java b/src/ch/epfl/maze/main/Program.java index db43a68..043f7e5 100644 --- a/src/ch/epfl/maze/main/Program.java +++ b/src/ch/epfl/maze/main/Program.java @@ -17,7 +17,6 @@ import ch.epfl.maze.util.Vector2D; /** * Mini-project main program that will run the simulations on a {@code Display}. */ - public class Program { /** @@ -26,7 +25,6 @@ public class Program { * @see #getMazeSimulation() * @see #getDaedalusSimulation() */ - public static void main(String[] args) { Simulation simulation; @@ -42,7 +40,6 @@ public class Program { * * @return A {@code MazeSimulation} to display */ - public static Simulation getMazeSimulation() { int[][] labyrinth = LabyrinthGenerator.getMedium(); Maze m = new Maze(labyrinth); @@ -72,7 +69,6 @@ public class Program { * * @return A {@code DaedalusSimulation} to display */ - public static Simulation getDaedalusSimulation() { int[][] labyrinth = LabyrinthGenerator.getPacMan(); Daedalus d = new Daedalus(labyrinth); @@ -97,4 +93,5 @@ public class Program { return simulation; } + } diff --git a/src/ch/epfl/maze/physical/Animal.java b/src/ch/epfl/maze/physical/Animal.java index 9123d82..0079d11 100644 --- a/src/ch/epfl/maze/physical/Animal.java +++ b/src/ch/epfl/maze/physical/Animal.java @@ -9,7 +9,6 @@ import ch.epfl.maze.util.Vector2D; * * @author Pacien TRAN-GIRARD */ - abstract public class Animal { private Vector2D position; @@ -19,7 +18,6 @@ abstract public class Animal { * * @param position Position of the animal in the labyrinth */ - public Animal(Vector2D position) { this.position = position; } @@ -33,7 +31,6 @@ abstract public class Animal { * World.getChoices(Vector2D)}) * @return The next direction of the animal, chosen in {@code choices} */ - abstract public Direction move(Direction[] choices); /** @@ -44,7 +41,6 @@ abstract public class Animal { * * @param dir Direction that the animal has taken */ - public final void update(Direction dir) { this.position = this.position.addDirectionTo(dir); } @@ -57,7 +53,6 @@ abstract public class Animal { * * @param position */ - public final void setPosition(Vector2D position) { this.position = position; } @@ -67,10 +62,10 @@ abstract public class Animal { * * @return Current position of animal. */ - public final Vector2D getPosition() { return this.position; } abstract public Animal copy(); + } diff --git a/src/ch/epfl/maze/physical/GhostPredator.java b/src/ch/epfl/maze/physical/GhostPredator.java index 8188c00..5408bf6 100644 --- a/src/ch/epfl/maze/physical/GhostPredator.java +++ b/src/ch/epfl/maze/physical/GhostPredator.java @@ -122,7 +122,7 @@ abstract public class GhostPredator extends Predator { /** * Calculates the Euclidean distance from the adjacent position at the given Direction to the target position. * - * @param dir The adjacent Direction + * @param dir The adjacent Direction * @param targetPosition The targeted position * @return The Euclidean distance between the two positions */ @@ -138,7 +138,7 @@ abstract public class GhostPredator extends Predator { * Selects the best Direction in the given choices by minimizing the Euclidean distance to the targeted position. * * @param targetPosition The targeted position - * @param choices An array of Direction choices + * @param choices An array of Direction choices * @return An array of optimal Direction choices */ private Direction[] selectBestPaths(Vector2D targetPosition, Direction[] choices) { diff --git a/src/ch/epfl/maze/physical/Maze.java b/src/ch/epfl/maze/physical/Maze.java index bff8791..51b9811 100644 --- a/src/ch/epfl/maze/physical/Maze.java +++ b/src/ch/epfl/maze/physical/Maze.java @@ -10,7 +10,6 @@ import java.util.List; * * @author Pacien TRAN-GIRARD */ - public final class Maze extends World { private final List animals; @@ -21,7 +20,6 @@ public final class Maze extends World { * * @param labyrinth Structure of the labyrinth, an NxM array of tiles */ - public Maze(int[][] labyrinth) { super(labyrinth); @@ -46,7 +44,6 @@ public final class Maze extends World { * @return true if the animal belongs to the world, false * otherwise. */ - public boolean hasAnimal(Animal a) { return this.animals.contains(a); } @@ -56,7 +53,6 @@ public final class Maze extends World { * * @param a The animal to add */ - public void addAnimal(Animal a) { a.setPosition(this.getStart()); this.animals.add(a); @@ -67,7 +63,6 @@ public final class Maze extends World { * * @param a The animal to remove */ - public void removeAnimal(Animal a) { boolean contained = this.animals.remove(a); if (contained) this.animalHistory.add(a); @@ -80,4 +75,5 @@ public final class Maze extends World { this.animalHistory.forEach(a -> this.addAnimal(a.copy())); this.animalHistory.clear(); } + } diff --git a/src/ch/epfl/maze/physical/World.java b/src/ch/epfl/maze/physical/World.java index f13b2b1..9afbd5e 100644 --- a/src/ch/epfl/maze/physical/World.java +++ b/src/ch/epfl/maze/physical/World.java @@ -12,7 +12,6 @@ import java.util.List; * * @author Pacien TRAN-GIRARD */ - public abstract class World { /* tiles constants */ @@ -25,7 +24,6 @@ public abstract class World { /** * Structure of the labyrinth, an NxM array of tiles */ - private final int[][] labyrinth; private final Vector2D start; @@ -36,7 +34,6 @@ public abstract class World { * * @param labyrinth Structure of the labyrinth, an NxM array of tiles */ - public World(int[][] labyrinth) { this.labyrinth = labyrinth; @@ -50,7 +47,6 @@ public abstract class World { * @param tileType Type of the tile * @return A Vector2D of the first occurrence of the given tile type */ - private Vector2D findFirstTileOfType(int tileType) { for (int x = 0; x < this.getWidth(); ++x) for (int y = 0; y < this.getHeight(); ++y) @@ -65,13 +61,11 @@ public abstract class World { * * @return true if no more moves can be made, false otherwise */ - abstract public boolean isSolved(); /** * Resets the world as when it was instantiated. */ - abstract public void reset(); /** @@ -79,7 +73,6 @@ public abstract class World { * * @return A list of all animals in the world */ - abstract public List getAnimals(); /** @@ -90,7 +83,6 @@ public abstract class World { * @return The tile number at position (x, y), or the NOTHING tile if x or y is * incorrect. */ - public final int getTile(int x, int y) { if (x < 0 || x >= this.getWidth()) return World.NOTHING; if (y < 0 || y >= this.getHeight()) return World.NOTHING; @@ -104,7 +96,6 @@ public abstract class World { * @param y Vertical coordinate * @return true if an animal can walk on tile, false otherwise */ - public final boolean isFree(int x, int y) { int tile = this.getTile(x, y); return !(tile == World.WALL || tile == World.NOTHING); @@ -116,7 +107,6 @@ public abstract class World { * @param position The position vector * @return true if an animal can walk on tile, false otherwise */ - public final boolean isFree(Vector2D position) { return this.isFree(position.getX(), position.getY()); } @@ -129,7 +119,6 @@ public abstract class World { * @param position A position in the maze * @return An array of all available choices at a position */ - public final Direction[] getChoices(Vector2D position) { List choices = new ArrayList<>(); for (Direction dir : Direction.POSSIBLE_DIRECTIONS) @@ -144,7 +133,6 @@ public abstract class World { * * @return The horizontal length of the labyrinth */ - public final int getWidth() { return this.labyrinth[0].length; } @@ -154,7 +142,6 @@ public abstract class World { * * @return The vertical length of the labyrinth */ - public final int getHeight() { return this.labyrinth.length; } @@ -165,7 +152,6 @@ public abstract class World { * * @return Start position of the labyrinth, null if none. */ - public final Vector2D getStart() { return this.start; } @@ -175,8 +161,8 @@ public abstract class World { * * @return Exit position of the labyrinth, null if none. */ - public final Vector2D getExit() { return this.exit; } + } diff --git a/src/ch/epfl/maze/physical/pacman/Pinky.java b/src/ch/epfl/maze/physical/pacman/Pinky.java index ebabc15..9c3d2c8 100644 --- a/src/ch/epfl/maze/physical/pacman/Pinky.java +++ b/src/ch/epfl/maze/physical/pacman/Pinky.java @@ -6,8 +6,6 @@ import ch.epfl.maze.physical.GhostPredator; import ch.epfl.maze.util.Direction; import ch.epfl.maze.util.Vector2D; -import java.util.Vector; - /** * Pink ghost from the Pac-Man game, targets 4 squares in front of its target. * @@ -16,6 +14,7 @@ import java.util.Vector; public class Pinky extends GhostPredator { private static final int TARGET_OFFSET = 4; + /** * Constructs a Pinky with a starting position. * diff --git a/src/ch/epfl/maze/physical/zoo/Hamster.java b/src/ch/epfl/maze/physical/zoo/Hamster.java index 3c903f5..7fa0b0d 100644 --- a/src/ch/epfl/maze/physical/zoo/Hamster.java +++ b/src/ch/epfl/maze/physical/zoo/Hamster.java @@ -16,7 +16,6 @@ import java.util.stream.Collectors; * * @author Pacien TRAN-GIRARD */ - public class Hamster extends ProbabilisticAnimal { private final List deadPaths; @@ -26,7 +25,6 @@ public class Hamster extends ProbabilisticAnimal { * * @param position Starting position of the hamster in the labyrinth */ - public Hamster(Vector2D position) { super(position); this.deadPaths = new ArrayList<>(); @@ -38,7 +36,6 @@ public class Hamster extends ProbabilisticAnimal { * @param choices An array of choices * @return An array of smart choices */ - private Direction[] excludeDeadPaths(Direction[] choices) { return (new ArrayList<>(Arrays.asList(choices))) .stream() @@ -51,7 +48,6 @@ public class Hamster extends ProbabilisticAnimal { * Moves without retracing directly its steps and by avoiding the dead-ends * it learns during its journey. */ - @Override public Direction move(Direction[] choices) { Direction[] smartChoices = this.excludeDeadPaths(choices); @@ -63,4 +59,5 @@ public class Hamster extends ProbabilisticAnimal { public Animal copy() { return new Hamster(this.getPosition()); } + } diff --git a/src/ch/epfl/maze/physical/zoo/Monkey.java b/src/ch/epfl/maze/physical/zoo/Monkey.java index 7bcf090..196b028 100644 --- a/src/ch/epfl/maze/physical/zoo/Monkey.java +++ b/src/ch/epfl/maze/physical/zoo/Monkey.java @@ -13,7 +13,6 @@ import java.util.List; * * @author Pacien TRAN-GIRARD */ - public class Monkey extends Animal { private Direction currentDirection; @@ -23,7 +22,6 @@ public class Monkey extends Animal { * * @param position Starting position of the monkey in the labyrinth */ - public Monkey(Vector2D position) { super(position); this.currentDirection = Direction.NONE; @@ -35,7 +33,6 @@ public class Monkey extends Animal { * @param choices An array of possible directions * @return The currentDirection to take according to the "left paw rule" */ - private Direction followLeft(Direction[] choices) { List choiceList = new ArrayList<>(Arrays.asList(choices)); Direction dir = this.currentDirection.rotateLeft(); @@ -60,7 +57,6 @@ public class Monkey extends Animal { /** * Moves according to the relative left wall that the monkey has to follow. */ - @Override public Direction move(Direction[] choices) { this.currentDirection = this.findDirection(choices); @@ -71,4 +67,5 @@ public class Monkey extends Animal { public Animal copy() { return new Monkey(this.getPosition()); } + } diff --git a/src/ch/epfl/maze/physical/zoo/Panda.java b/src/ch/epfl/maze/physical/zoo/Panda.java index dc1198e..aa35efe 100644 --- a/src/ch/epfl/maze/physical/zoo/Panda.java +++ b/src/ch/epfl/maze/physical/zoo/Panda.java @@ -104,7 +104,7 @@ public class Panda extends ProbabilisticAnimal { * avoiding intersections over-marking. * * @param choices An array of possible Directions - * @param choice The selected Direction + * @param choice The selected Direction * @return T(the current position should be marked) */ private boolean shouldMarkCurrentPosition(Direction[] choices, Direction choice) { diff --git a/src/ch/epfl/maze/physical/zoo/SpaceInvader.java b/src/ch/epfl/maze/physical/zoo/SpaceInvader.java index f5963b1..d03d280 100644 --- a/src/ch/epfl/maze/physical/zoo/SpaceInvader.java +++ b/src/ch/epfl/maze/physical/zoo/SpaceInvader.java @@ -18,7 +18,6 @@ import ch.epfl.maze.util.Vector2D; * * @see ch.epfl.maze.tests.Competition Competition */ - public class SpaceInvader extends Animal { /** @@ -26,7 +25,6 @@ public class SpaceInvader extends Animal { * * @param position Starting position of the mouse in the labyrinth */ - public SpaceInvader(Vector2D position) { super(position); // TODO (bonus) @@ -35,7 +33,6 @@ public class SpaceInvader extends Animal { /** * Moves according to (... please complete with as many details as you can). */ - @Override public Direction move(Direction[] choices) { // TODO (bonus) @@ -47,4 +44,5 @@ public class SpaceInvader extends Animal { // TODO (bonus) return null; } + } diff --git a/src/ch/epfl/maze/simulation/DaedalusSimulation.java b/src/ch/epfl/maze/simulation/DaedalusSimulation.java index 8b60b57..90ff4a7 100644 --- a/src/ch/epfl/maze/simulation/DaedalusSimulation.java +++ b/src/ch/epfl/maze/simulation/DaedalusSimulation.java @@ -13,7 +13,6 @@ import java.util.*; * predator and prey in a Daedalus, as well as the animation by notifying * changes to it. The simulation finishes when every prey has been caught. */ - public final class DaedalusSimulation implements Simulation { /* limit to the step counter, over which the animals are considered lost */ @@ -33,7 +32,6 @@ public final class DaedalusSimulation implements Simulation { * * @param daedalus The daedalus to simulate */ - public DaedalusSimulation(Daedalus daedalus) { mDaedalus = daedalus; mArrivalTimes = new TreeMap>(Collections.reverseOrder()); @@ -162,7 +160,6 @@ public final class DaedalusSimulation implements Simulation { * @param listener The listener to which the function will notify the changes * (can be null) */ - private void movePredators(Animation listener) { List predators = mDaedalus.getPredators(); for (int i = 0; i < predators.size(); i++) { @@ -231,7 +228,6 @@ public final class DaedalusSimulation implements Simulation { * @param listener The listener to which the function will notify the changes * (can be null) */ - private void movePreys(Animation listener) { List preys = mDaedalus.getPreys(); Action action; @@ -303,7 +299,6 @@ public final class DaedalusSimulation implements Simulation { * @param listener The listener to which the function will notify the changes * (can be null) */ - private void checkCollisions(Animation listener) { List predators = mDaedalus.getPredators(); List preys = mDaedalus.getPreys(); @@ -346,4 +341,5 @@ public final class DaedalusSimulation implements Simulation { } } } + } diff --git a/src/ch/epfl/maze/simulation/MazeSimulation.java b/src/ch/epfl/maze/simulation/MazeSimulation.java index 3fd0e52..2108f54 100644 --- a/src/ch/epfl/maze/simulation/MazeSimulation.java +++ b/src/ch/epfl/maze/simulation/MazeSimulation.java @@ -18,7 +18,6 @@ import java.util.TreeMap; * the animation by notifying the changes to it. The simulation finishes when * every animal has found the exit. */ - public final class MazeSimulation implements Simulation { /* limit to the step counter, over which the animals are considered lost */ @@ -34,7 +33,6 @@ public final class MazeSimulation implements Simulation { * * @param maze The maze to simulate */ - public MazeSimulation(Maze maze) { mMaze = maze; mArrivalTimes = new TreeMap>(); @@ -140,7 +138,6 @@ public final class MazeSimulation implements Simulation { * @param listener The listener to which the function will notify the changes * (can be null) */ - private void moveAnimals(Animation listener) { List animals = mMaze.getAnimals(); for (int i = 0; i < animals.size(); i++) { @@ -205,4 +202,5 @@ public final class MazeSimulation implements Simulation { } } } + } diff --git a/src/ch/epfl/maze/simulation/Simulation.java b/src/ch/epfl/maze/simulation/Simulation.java index ab2fb84..d373d2f 100644 --- a/src/ch/epfl/maze/simulation/Simulation.java +++ b/src/ch/epfl/maze/simulation/Simulation.java @@ -11,7 +11,6 @@ import java.util.Map; * The {@code Simulation} interface defines a set of rules that must be * fulfilled in order to be displayed. */ - public interface Simulation { /** @@ -21,7 +20,6 @@ public interface Simulation { * @param listener The listener to which the function will notify the changes * (can be null) */ - public void move(Animation listener); /** @@ -29,7 +27,6 @@ public interface Simulation { * * @return true if no more moves can be made, false otherwise */ - public boolean isOver(); /** @@ -37,7 +34,6 @@ public interface Simulation { * * @return The {@code World} that is being simulated */ - public World getWorld(); /** @@ -45,7 +41,6 @@ public interface Simulation { * * @return The current step counter */ - public int getSteps(); /** @@ -55,7 +50,6 @@ public interface Simulation { * @return Map of steps done by animals which have accomplished the * simulation */ - public Map> getArrivalTimes(); /** @@ -65,18 +59,16 @@ public interface Simulation { * @return A {@code String} containing the top 10 animals which have * accomplished the simulation */ - public String getRecordTable(); /** * Restarts the simulation from the beginning. */ - public void restart(); /** * Stops abruptly the simulation. */ - public void stop(); + } diff --git a/src/ch/epfl/maze/tests/AnimalTest.java b/src/ch/epfl/maze/tests/AnimalTest.java index 4a590ae..123c038 100644 --- a/src/ch/epfl/maze/tests/AnimalTest.java +++ b/src/ch/epfl/maze/tests/AnimalTest.java @@ -9,13 +9,11 @@ import org.junit.Test; /** * Test case for {@code Animal} implementation. */ - public class AnimalTest extends TestCase { /** * Test case for {@code getPosition()}. */ - @Test public void testGetPosition() { Animal animal = new MockAnimal(new Vector2D(2, 1)); @@ -27,7 +25,6 @@ public class AnimalTest extends TestCase { /** * Test case for {@code setPosition(Vector2D position)}. */ - @Test public void testSetPosition() { Animal animal = new MockAnimal(new Vector2D(2, 1)); @@ -40,7 +37,6 @@ public class AnimalTest extends TestCase { /** * Test case for {@code update(Direction dir)}. */ - @Test public void testUpdate() { Animal animal = new MockAnimal(new Vector2D(2, 1)); @@ -69,7 +65,6 @@ public class AnimalTest extends TestCase { /** * Mock class that makes {@code Animal} concrete. */ - private class MockAnimal extends Animal { /** @@ -77,7 +72,6 @@ public class AnimalTest extends TestCase { * * @param labyrinth Actual maze */ - public MockAnimal(Vector2D position) { super(position); } @@ -92,4 +86,5 @@ public class AnimalTest extends TestCase { return null; } } + } diff --git a/src/ch/epfl/maze/tests/Competition.java b/src/ch/epfl/maze/tests/Competition.java index ccbbe73..10a6c84 100644 --- a/src/ch/epfl/maze/tests/Competition.java +++ b/src/ch/epfl/maze/tests/Competition.java @@ -31,7 +31,6 @@ import static org.junit.Assert.assertTrue; * against it. * */ - public class Competition { static final String COMPETITION_MAZE_FILE = "labyrinth.txt"; @@ -42,7 +41,6 @@ public class Competition { * Launches the competition between the {@code SpaceInvader} and the other * animals. */ - @BeforeClass public static void setUpClass() { int[][] labyrinth = LabyrinthGenerator.readFromFile(COMPETITION_MAZE_FILE); @@ -112,7 +110,6 @@ public class Competition { /** * Determines if the {@code SpaceInvader} has beaten the {@code Mouse}. */ - @Test public void testVSMouse() { assertTrue("The SpaceInvader has not beaten the Mouse", rivalries.get("Mouse") > 0); @@ -121,7 +118,6 @@ public class Competition { /** * Determines if the {@code SpaceInvader} has beaten the {@code Hamster}. */ - @Test public void testVSHamster() { assertTrue("The SpaceInvader has not beaten the Hamster", rivalries.get("Hamster") > 0); @@ -130,7 +126,6 @@ public class Competition { /** * Determines if the {@code SpaceInvader} has beaten the {@code Monkey}. */ - @Test public void testVSMonkey() { assertTrue("The SpaceInvader has not beaten the Monkey", rivalries.get("Monkey") > 0); @@ -139,7 +134,6 @@ public class Competition { /** * Determines if the {@code SpaceInvader} has beaten the {@code Bear}. */ - @Test public void testVSBear() { assertTrue("The SpaceInvader has not beaten the Bear", rivalries.get("Bear") > 0); @@ -148,9 +142,9 @@ public class Competition { /** * Determines if the {@code SpaceInvader} has beaten the {@code Panda}. */ - @Test public void testVSPanda() { assertTrue("The SpaceInvader has not beaten the Panda", rivalries.get("Panda") > 0); } + } diff --git a/src/ch/epfl/maze/tests/DaedalusTest.java b/src/ch/epfl/maze/tests/DaedalusTest.java index 070b70d..6087338 100644 --- a/src/ch/epfl/maze/tests/DaedalusTest.java +++ b/src/ch/epfl/maze/tests/DaedalusTest.java @@ -13,7 +13,6 @@ import org.junit.Test; /** * Test case for {@code Daedalus} implementation. */ - public class DaedalusTest extends TestCase { private final static int[][] LABYRINTH = { @@ -25,7 +24,6 @@ public class DaedalusTest extends TestCase { /** * Test case for several methods in {@code Daedalus}. */ - @Test public void testGeneral() { Daedalus daedalus = new Daedalus(LABYRINTH); @@ -83,7 +81,6 @@ public class DaedalusTest extends TestCase { /** * Test case for {@code reset()}. */ - @Test public void testReset() { Daedalus daedalus = new Daedalus(LABYRINTH); @@ -117,4 +114,5 @@ public class DaedalusTest extends TestCase { assertTrue("Animals in Daedalus should be not null", retrievedPred != null); assertTrue("Animals in Daedalus should be not null", retrievedPrey != null); } + } diff --git a/src/ch/epfl/maze/tests/GhostsTest.java b/src/ch/epfl/maze/tests/GhostsTest.java index c8c71a9..f4e0c2e 100644 --- a/src/ch/epfl/maze/tests/GhostsTest.java +++ b/src/ch/epfl/maze/tests/GhostsTest.java @@ -19,7 +19,6 @@ import org.junit.Test; /** * Test suite for ghosts implementation. */ - public class GhostsTest extends TestCase { public static final boolean DEBUG = false; @@ -29,7 +28,6 @@ public class GhostsTest extends TestCase { *

* In this case, Blinky should go straight to the PacMan's position. */ - @Test public void testBlinky() { int[][] labyrinth = LabyrinthGenerator.getDebugBlinky(); @@ -50,7 +48,6 @@ public class GhostsTest extends TestCase { *

* In this case, Pinky should go back and forth. */ - @Test public void testPinky() { int[][] labyrinth = LabyrinthGenerator.getDebugPinky(); @@ -71,7 +68,6 @@ public class GhostsTest extends TestCase { *

* In this case, Inky should target the red tile of the labyrinth. */ - @Test public void testInky() { int[][] labyrinth = LabyrinthGenerator.getDebugInky(); @@ -93,7 +89,6 @@ public class GhostsTest extends TestCase { *

* In this case, Clyde should go back and forth. */ - @Test public void testClyde() { int[][] labyrinth = LabyrinthGenerator.getDebugClyde(); @@ -112,7 +107,6 @@ public class GhostsTest extends TestCase { /** * Mock class to create a dummy PacMan in our testing unit. */ - private class PacMan extends Prey { private boolean mMoves; @@ -123,7 +117,6 @@ public class GhostsTest extends TestCase { * @param position Starting position of PacMan in the labyrinth * @param moves Determines if the dummy PacMan will move back and forth */ - public PacMan(Vector2D position, boolean moves) { super(position); mMoves = moves; @@ -142,4 +135,5 @@ public class GhostsTest extends TestCase { return new PacMan(getPosition(), mMoves); } } + } diff --git a/src/ch/epfl/maze/tests/MazeTest.java b/src/ch/epfl/maze/tests/MazeTest.java index c0660db..52651e1 100644 --- a/src/ch/epfl/maze/tests/MazeTest.java +++ b/src/ch/epfl/maze/tests/MazeTest.java @@ -10,7 +10,6 @@ import org.junit.Test; /** * Test case for {@code Maze} implementation. */ - public class MazeTest extends TestCase { private final static int[][] LABYRINTH = { @@ -22,7 +21,6 @@ public class MazeTest extends TestCase { /** * Test case for several methods in {@code Maze}. */ - @Test public void testGeneral() { Maze maze = new Maze(LABYRINTH); @@ -62,7 +60,6 @@ public class MazeTest extends TestCase { /** * Test case for {@code reset()}. */ - @Test public void testReset() { Maze maze = new Maze(LABYRINTH); @@ -85,4 +82,5 @@ public class MazeTest extends TestCase { assertTrue("Animal in Maze should be a Mouse", retrieved != null); } + } diff --git a/src/ch/epfl/maze/tests/WorldTest.java b/src/ch/epfl/maze/tests/WorldTest.java index dccd1ab..845c689 100644 --- a/src/ch/epfl/maze/tests/WorldTest.java +++ b/src/ch/epfl/maze/tests/WorldTest.java @@ -15,7 +15,6 @@ import static org.junit.Assert.assertArrayEquals; /** * Test case for {@code World} implementation. */ - public class WorldTest extends TestCase { /* sample labyrinth */ @@ -55,7 +54,6 @@ public class WorldTest extends TestCase { /** * Test case for {@code getTile(int x, int y)}. */ - @Test public void testGetTile() { World world = new ConcreteWorld(LABYRINTH_SAMPLE); @@ -75,7 +73,6 @@ public class WorldTest extends TestCase { /** * Test case for {@code isFree(int x, int y)}. */ - @Test public void testIsFree() { World world = new ConcreteWorld(LABYRINTH_SAMPLE); @@ -93,7 +90,6 @@ public class WorldTest extends TestCase { /** * Test case for {@code getWidth()}. */ - @Test public void testGetWidth() { World world = new ConcreteWorld(LABYRINTH_SAMPLE); @@ -105,7 +101,6 @@ public class WorldTest extends TestCase { /** * Test case for {@code getHeight()}. */ - @Test public void testGetHeight() { World world = new ConcreteWorld(LABYRINTH_SAMPLE); @@ -117,7 +112,6 @@ public class WorldTest extends TestCase { /** * Test case for {@code getStart()}. */ - @Test public void testGetStart() { World world = new ConcreteWorld(LABYRINTH_SAMPLE); @@ -129,7 +123,6 @@ public class WorldTest extends TestCase { /** * Test case for {@code getExit()}. */ - @Test public void testGetExit() { World world = new ConcreteWorld(LABYRINTH_SAMPLE); @@ -144,7 +137,6 @@ public class WorldTest extends TestCase { * Test case for {@code getChoices(Vector2D position)} * when there are 0 choices. */ - @Test public void testZeroChoice() { World world = new ConcreteWorld(LABYRINTH_STUCK); @@ -158,7 +150,6 @@ public class WorldTest extends TestCase { * Test case for {@code getChoices(Vector2D position)} * when there is 1 choice. */ - @Test public void testOneChoice() { World world = new ConcreteWorld(LABYRINTH_CORRIDOR); @@ -185,7 +176,6 @@ public class WorldTest extends TestCase { * Test case for {@code getChoices(Vector2D position)} * when there are 2 choices. */ - @Test public void testTwoChoices() { World world = new ConcreteWorld(LABYRINTH_DOGHNUT); @@ -226,7 +216,6 @@ public class WorldTest extends TestCase { * Test case for {@code getChoices(Vector2D position)} * when there are 3 choices. */ - @Test public void testThreeChoices() { World world = new ConcreteWorld(LABYRINTH_SQUARE); @@ -257,7 +246,6 @@ public class WorldTest extends TestCase { * Test case for {@code getChoices(Vector2D position)} * when there are 4 choices. */ - @Test public void testFourChoices() { World world = new ConcreteWorld(LABYRINTH_SQUARE); @@ -278,7 +266,6 @@ public class WorldTest extends TestCase { * @param result The choices computed with method {@code getChoices(position)} * @param expected The choices expected to be present */ - private void checkChoices(Direction[] result, Direction[] expected) { // checks that array was initialized assertNotNull(result); @@ -292,7 +279,6 @@ public class WorldTest extends TestCase { /** * Mock class that makes {@code World} concrete. */ - private final class ConcreteWorld extends World { /** @@ -300,7 +286,6 @@ public class WorldTest extends TestCase { * * @param labyrinth Actual maze */ - public ConcreteWorld(int[][] labyrinth) { super(labyrinth); } @@ -320,4 +305,5 @@ public class WorldTest extends TestCase { return null; } } + } diff --git a/src/ch/epfl/maze/tests/ZooTest.java b/src/ch/epfl/maze/tests/ZooTest.java index 04b6a79..03a84b3 100644 --- a/src/ch/epfl/maze/tests/ZooTest.java +++ b/src/ch/epfl/maze/tests/ZooTest.java @@ -12,7 +12,6 @@ import org.junit.Test; /** * Test cases for animals implementation. */ - public class ZooTest extends TestCase { public static final boolean DEBUG = false; @@ -22,7 +21,6 @@ public class ZooTest extends TestCase { *

* The Mouse should go forward and never retrace its steps. */ - @Test public void testMouse() { int[][] labyrinth = LabyrinthGenerator.getDebugMouse(); @@ -42,7 +40,6 @@ public class ZooTest extends TestCase { *

* The Hamster should never revisit a dead-end it has already visited. */ - @Test public void testHamster() { int[][] labyrinth = LabyrinthGenerator.getDebugHamster(); @@ -62,7 +59,6 @@ public class ZooTest extends TestCase { *

* The Monkey should go directly to the exit without taking any dead-end. */ - @Test public void testMonkey() { int[][] labyrinth = LabyrinthGenerator.getDebugMonkey(); @@ -84,7 +80,6 @@ public class ZooTest extends TestCase { * it loops infinitely in this maze, it means that it does not properly * count the turns it makes. */ - @Test public void testBear1() { int[][] labyrinth = LabyrinthGenerator.getDebugBear1(); @@ -105,7 +100,6 @@ public class ZooTest extends TestCase { * If the Bear loops infinitely in this maze, it means that it does not * properly count the turns it makes. */ - @Test public void testBear2() { int[][] labyrinth = LabyrinthGenerator.getDebugBear2(); @@ -126,7 +120,6 @@ public class ZooTest extends TestCase { * When the Panda comes back to the intersection, then it must leave the * position marked once and go back into the loop. */ - @Test public void testPanda1() { int[][] labyrinth = LabyrinthGenerator.getDebugPanda1(); @@ -147,7 +140,6 @@ public class ZooTest extends TestCase { * The Panda must mark the intersection twice only the very last time it * walks on it. */ - @Test public void testPanda2() { int[][] labyrinth = LabyrinthGenerator.getDebugPanda2(); @@ -167,7 +159,6 @@ public class ZooTest extends TestCase { *

* The Bear should leave the maze while the Monkey should loop infinitely. */ - @Test public void testBearVsMonkey() { int[][] labyrinth = LabyrinthGenerator.getBearVsMonkey(); @@ -188,7 +179,6 @@ public class ZooTest extends TestCase { * The Panda should leave the maze earlier than the Hamster with a higher * probability than the Hamster. */ - @Test public void testPandaVsHamster() { int[][] labyrinth = LabyrinthGenerator.getPandaVsHamster(); @@ -202,4 +192,5 @@ public class ZooTest extends TestCase { Display display = new Display(simulation); display.run(); } + } 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