From e3f8e4276d87f2dba10395a882dc4673b65b4e89 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Fri, 8 Apr 2016 19:20:18 +0200 Subject: Use stream for explosion generation --- src/ch/epfl/xblast/server/Bomb.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/ch') diff --git a/src/ch/epfl/xblast/server/Bomb.java b/src/ch/epfl/xblast/server/Bomb.java index 3b1203b..f32960f 100644 --- a/src/ch/epfl/xblast/server/Bomb.java +++ b/src/ch/epfl/xblast/server/Bomb.java @@ -6,9 +6,10 @@ import ch.epfl.xblast.Cell; import ch.epfl.xblast.Direction; import ch.epfl.xblast.PlayerID; -import java.util.ArrayList; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; +import java.util.stream.Stream; /** * A Bomb. @@ -106,11 +107,9 @@ public final class Bomb { * @return the explosion */ public List>> explosion() { - List>> explosion = new ArrayList<>(); - for (Direction dir : Direction.values()) { - explosion.add(this.explosionArmTowards(dir)); - } - return explosion; + return Stream.of(Direction.values()) + .map(this::explosionArmTowards) + .collect(Collectors.toList()); } } -- cgit v1.2.3