Coverage Summary for Class: Block (it.polimi.ingsw.view.model)
Class | Class, % | Method, % | Line, % |
---|---|---|---|
Block | 100% (1/ 1) | 100% (6/ 6) | 100% (17/ 17) |
1 package it.polimi.ingsw.view.model;
2
3 import java.util.ArrayList;
4 import java.util.Arrays;
5 import java.util.List;
6
7 /**
8 * A Block of the Board
9 */
10 public class Block implements RawObj {
11 /**
12 * Type of the block
13 */
14 private final String typeBlock;
15 /**
16 * Owner of the block, default null
17 */
18 private final String owner;
19 /**
20 * Color of the worker if it is a worker, default null
21 */
22 private final String color;
23
24 /**
25 * Block Constructor
26 *
27 * @param block type block
28 * @param owner block owner
29 * @param color block color
30 */
31 public Block(String block, String owner, String color) {
32 this.owner = owner;
33 this.typeBlock = block;
34 this.color = color;
35 }
36
37 /**
38 * Block Constructor from another Block
39 *
40 * @param toClone block to clone
41 */
42 public Block(Block toClone) {
43 this.owner = toClone.owner;
44 this.typeBlock = toClone.typeBlock;
45 this.color = toClone.color;
46 }
47
48 @Override
49 public List<String> getRawData() {
50 String toRes = typeBlock;
51 if (owner != null)
52 toRes = color;
53 return new ArrayList<>(Arrays.asList(toRes));
54 }
55
56 /**
57 * Get block type
58 *
59 * @return block type
60 */
61 public String getTypeBlock() {
62 return typeBlock;
63 }
64
65 /**
66 * Get block owner
67 *
68 * @return block owner, if it is not a worker is null
69 */
70 public String getOwner() {
71 return owner;
72 }
73
74 /**
75 * Get block color
76 *
77 * @return block color, if it is not a worker is null
78 */
79 public String getColor() {
80 return color;
81 }
82 }