From 59d35ae34c4513f54decf056e944190d7e9926f0 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 15 Mar 2016 13:44:43 +0100 Subject: Reformat provided classes --- .../epfl/xblast/server/debug/GameStatePrinter.java | 56 +++++++++++++++------- test/ch/epfl/xblast/namecheck/NameCheck04.java | 19 ++++---- 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/src/ch/epfl/xblast/server/debug/GameStatePrinter.java b/src/ch/epfl/xblast/server/debug/GameStatePrinter.java index 240446b..ea8b360 100644 --- a/src/ch/epfl/xblast/server/debug/GameStatePrinter.java +++ b/src/ch/epfl/xblast/server/debug/GameStatePrinter.java @@ -1,24 +1,32 @@ package ch.epfl.xblast.server.debug; -import java.util.List; - import ch.epfl.xblast.Cell; import ch.epfl.xblast.server.Block; import ch.epfl.xblast.server.Board; import ch.epfl.xblast.server.GameState; import ch.epfl.xblast.server.Player; +import java.util.List; + +/** + * Game state printer utility class that outputs the board to the terminal. + * + * @author EPFL + */ public final class GameStatePrinter { - private GameStatePrinter() {} + + private GameStatePrinter() { + } public static void printGameState(GameState s) { List ps = s.alivePlayers(); Board board = s.board(); for (int y = 0; y < Cell.ROWS; ++y) { - xLoop: for (int x = 0; x < Cell.COLUMNS; ++x) { + xLoop: + for (int x = 0; x < Cell.COLUMNS; ++x) { Cell c = new Cell(x, y); - for (Player p: ps) { + for (Player p : ps) { if (p.position().containingCell().equals(c)) { System.out.print(stringForPlayer(p)); continue xLoop; @@ -35,23 +43,39 @@ public final class GameStatePrinter { StringBuilder b = new StringBuilder(); b.append(p.id().ordinal() + 1); switch (p.direction()) { - case N: b.append('^'); break; - case E: b.append('>'); break; - case S: b.append('v'); break; - case W: b.append('<'); break; + case N: + b.append('^'); + break; + case E: + b.append('>'); + break; + case S: + b.append('v'); + break; + case W: + b.append('<'); + break; } return b.toString(); } private static String stringForBlock(Block b) { switch (b) { - case FREE: return " "; - case INDESTRUCTIBLE_WALL: return "##"; - case DESTRUCTIBLE_WALL: return "??"; - case CRUMBLING_WALL: return "¿¿"; - case BONUS_BOMB: return "+b"; - case BONUS_RANGE: return "+r"; - default: throw new Error(); + case FREE: + return " "; + case INDESTRUCTIBLE_WALL: + return "##"; + case DESTRUCTIBLE_WALL: + return "??"; + case CRUMBLING_WALL: + return "¿¿"; + case BONUS_BOMB: + return "+b"; + case BONUS_RANGE: + return "+r"; + default: + throw new Error(); } } + } diff --git a/test/ch/epfl/xblast/namecheck/NameCheck04.java b/test/ch/epfl/xblast/namecheck/NameCheck04.java index b6adc8c..dc6cfb2 100644 --- a/test/ch/epfl/xblast/namecheck/NameCheck04.java +++ b/test/ch/epfl/xblast/namecheck/NameCheck04.java @@ -1,28 +1,24 @@ package ch.epfl.xblast.namecheck; -import java.util.List; -import java.util.Optional; - import ch.epfl.cs108.Sq; import ch.epfl.xblast.Cell; import ch.epfl.xblast.Lists; import ch.epfl.xblast.PlayerID; import ch.epfl.xblast.Time; -import ch.epfl.xblast.server.Block; -import ch.epfl.xblast.server.Board; -import ch.epfl.xblast.server.Bomb; -import ch.epfl.xblast.server.Bonus; -import ch.epfl.xblast.server.GameState; -import ch.epfl.xblast.server.Player; -import ch.epfl.xblast.server.Ticks; +import ch.epfl.xblast.server.*; + +import java.util.List; +import java.util.Optional; /** * Classe abstraite utilisant tous les éléments de l'étape 4, pour essayer de * garantir que ceux-ci ont le bon nom et les bons types. Attention, ceci n'est * pas un test unitaire, et n'a pas pour but d'être exécuté! + * + * @author EPFL */ - abstract class NameCheck04 { + void checkLists() { List l1 = null; List> p1 = Lists.permutations(l1); @@ -78,4 +74,5 @@ abstract class NameCheck04 { ps = s.isGameOver() ? s.alivePlayers() : s.players(); System.out.println(w); } + } -- cgit v1.2.3