Coverage Summary for Class: PawnColour (it.polimi.ingsw.Model.Enums)
Class |
Class, %
|
Method, %
|
Branch, %
|
Line, %
|
PawnColour |
100%
(1/1)
|
66,7%
(2/3)
|
0%
(0/20)
|
46,2%
(6/13)
|
1 package it.polimi.ingsw.Model.Enums;
2
3 import java.io.Serial;
4 import java.io.Serializable;
5
6 /**
7 * Represents the colour of many pawns on the game boards, like Students and Teachers.
8 */
9 public enum PawnColour implements Serializable {
10 GREEN,
11 RED,
12 YELLOW,
13 PINK,
14 BLUE;
15 @Serial
16 private static final long serialVersionUID = 125L; // convention: 1 for model, (01 -> 99) for objects
17
18 /**
19 * Convert a string to a valid PawnColour
20 *
21 * @param text string containing a colour
22 * @return the appropriate PawnColour or null when the string does not represent a valid pawnColour
23 */
24 public static PawnColour getPawnColourFromText(String text) {
25 switch (text.toUpperCase().trim()) {
26 case "RED" -> {
27 return PawnColour.RED;
28 }
29 case "BLUE" -> {
30 return PawnColour.BLUE;
31 }
32 case "PINK" -> {
33 return PawnColour.PINK;
34 }
35 case "YELLOW" -> {
36 return PawnColour.YELLOW;
37 }
38 case "GREEN" -> {
39 return PawnColour.GREEN;
40 }
41 }
42 return null;
43 }
44 }