aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothée Floure2016-03-31 12:54:35 +0200
committerTimothée Floure2016-03-31 12:54:35 +0200
commita5f3aa729dfad19f3979b01f0a6f9916ac968698 (patch)
treeedaffbcd935f7da00d460a30fd117871d0451f58
parent5e2797946a3d63de9142d79b241788e2284f8eab (diff)
downloadxblast-a5f3aa729dfad19f3979b01f0a6f9916ac968698.tar.gz
Fix encapsulation failure in Board class
-rw-r--r--src/ch/epfl/xblast/server/Board.java6
1 files changed, 4 insertions, 2 deletions
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;
5import ch.epfl.xblast.Lists; 5import ch.epfl.xblast.Lists;
6 6
7import java.util.ArrayList; 7import java.util.ArrayList;
8import java.util.Collections;
8import java.util.List; 9import java.util.List;
9 10
10/** 11/**
@@ -55,7 +56,7 @@ public final class Board {
55 if (blocks == null || blocks.size() != BLOCKS_LIST_SIZE) 56 if (blocks == null || blocks.size() != BLOCKS_LIST_SIZE)
56 throw new IllegalArgumentException(); 57 throw new IllegalArgumentException();
57 58
58 this.blocks = blocks; 59 this.blocks = new ArrayList<>(blocks);
59 } 60 }
60 61
61 /** 62 /**
@@ -148,6 +149,7 @@ public final class Board {
148 * @return a list of the Sequences of blocks of the board. 149 * @return a list of the Sequences of blocks of the board.
149 */ 150 */
150 public List<Sq<Block>> getBlocks() { 151 public List<Sq<Block>> getBlocks() {
151 return blocks; 152 List<Sq<Block>> immutableBlocks = Collections.unmodifiableList(new ArrayList<>(blocks));
153 return immutableBlocks;
152 } 154 }
153} 155}