From b0356d4ff6694ccc7f8fae1766b73b0e99c78ed9 Mon Sep 17 00:00:00 2001 From: Timothée Floure Date: Tue, 8 Mar 2016 23:16:12 +0100 Subject: Import NameCheck04 and GaneStatePrinter (given files for the week 4) --- test/ch/epfl/xblast/namecheck/NameCheck04.java | 81 ++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 test/ch/epfl/xblast/namecheck/NameCheck04.java (limited to 'test') diff --git a/test/ch/epfl/xblast/namecheck/NameCheck04.java b/test/ch/epfl/xblast/namecheck/NameCheck04.java new file mode 100644 index 0000000..b6adc8c --- /dev/null +++ b/test/ch/epfl/xblast/namecheck/NameCheck04.java @@ -0,0 +1,81 @@ +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; + +/** + * 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é! + */ + +abstract class NameCheck04 { + void checkLists() { + List l1 = null; + List> p1 = Lists.permutations(l1); + List>> p2 = Lists.permutations(p1); + System.out.println(p2); + } + + void checkBonus(boolean x) { + Bonus b = x ? Bonus.INC_BOMB : Bonus.INC_RANGE; + Player p = null; + p = b.applyTo(p); + } + + void checkBlock(Block b) { + b = b.isBonus() ? Block.BONUS_BOMB : Block.BONUS_RANGE; + Bonus s = b.associatedBonus(); + System.out.println(s); + } + + void checkTime() { + Optional o; + o = Optional.of(Time.S_PER_MIN); + o = Optional.of(Time.MS_PER_S); + o = Optional.of(Time.US_PER_S); + o = Optional.of(Time.NS_PER_S); + System.out.println(o); + } + + void checkTicks() { + Optional o; + o = Optional.of(Ticks.TICKS_PER_SECOND); + o = Optional.of(Ticks.TICK_NANOSECOND_DURATION); + o = Optional.of(Ticks.TOTAL_TICKS); + System.out.println(o); + } + + void checkGameState() { + int ts = 0; + Board b = null; + List ps = null; + List bs = null; + List>> es = null; + List> xs = null; + GameState s = new GameState(ts, b, ps, bs, es, xs); + s = new GameState(b, ps); + ts = s.ticks(); + if (s.isGameOver()) { + Optional t = Optional.of(s.remainingTime()); + System.out.println(t.get()); + } + Optional w = s.winner(); + b = s.board(); + ps = s.isGameOver() ? s.alivePlayers() : s.players(); + System.out.println(w); + } +} -- cgit v1.2.3 From 741cb9da501b8c6e9e5fa006e5c2c9df0b4616f8 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 15 Mar 2016 11:51:31 +0100 Subject: Add List permutation function and its test --- test/ch/epfl/xblast/ListsTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') diff --git a/test/ch/epfl/xblast/ListsTest.java b/test/ch/epfl/xblast/ListsTest.java index b898399..b18b05e 100644 --- a/test/ch/epfl/xblast/ListsTest.java +++ b/test/ch/epfl/xblast/ListsTest.java @@ -4,6 +4,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; +import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -48,4 +49,18 @@ public class ListsTest { assertEquals(mirrored.get(i), mirrored.get(mirrored.size() - 1 - i)); } + @Test + public void isListPermuted() { + List sampleList = Arrays.asList(1, 2, 3); + List> expected = new LinkedList<>(); + expected.add(Arrays.asList(1, 2, 3)); + expected.add(Arrays.asList(2, 1, 3)); + expected.add(Arrays.asList(2, 3, 1)); + expected.add(Arrays.asList(1, 3, 2)); + expected.add(Arrays.asList(3, 1, 2)); + expected.add(Arrays.asList(3, 2, 1)); + + assertEquals(expected, Lists.permutations(sampleList)); + } + } -- cgit v1.2.3 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 --- test/ch/epfl/xblast/namecheck/NameCheck04.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'test') 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