From a5f3aa729dfad19f3979b01f0a6f9916ac968698 Mon Sep 17 00:00:00 2001 From: Timothée Floure Date: Thu, 31 Mar 2016 12:54:35 +0200 Subject: Fix encapsulation failure in Board class --- src/ch/epfl/xblast/server/Board.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ch/epfl/xblast/server/Board.java b/src/ch/epfl/xblast/server/Board.java index f2a3c89..d7ca706 100644 --- a/src/ch/epfl/xblast/server/Board.java +++ b/src/ch/epfl/xblast/server/Board.java @@ -5,6 +5,7 @@ import ch.epfl.xblast.Cell; import ch.epfl.xblast.Lists; import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -55,7 +56,7 @@ public final class Board { if (blocks == null || blocks.size() != BLOCKS_LIST_SIZE) throw new IllegalArgumentException(); - this.blocks = blocks; + this.blocks = new ArrayList<>(blocks); } /** @@ -148,6 +149,7 @@ public final class Board { * @return a list of the Sequences of blocks of the board. */ public List> getBlocks() { - return blocks; + List> immutableBlocks = Collections.unmodifiableList(new ArrayList<>(blocks)); + return immutableBlocks; } } -- cgit v1.2.3