Coverage Summary for Class: TowerColour (it.polimi.ingsw.Model.Enums)
| Class | Class, % | Method, % | Branch, % | Line, % | 
|---|---|---|---|---|
| TowerColour | 100% (1/1) | 100% (5/5) | 75% (3/4) | 90% (9/10) | 
1 package it.polimi.ingsw.Model.Enums; 2 3 import java.io.Serial; 4 import java.io.Serializable; 5 6 /** 7 * Towers are bound to a colour, and each colour is bound to a team. This enum represents the colour-team link 8 */ 9 public enum TowerColour implements Serializable { 10 BLACK(TeamID.ONE), 11 WHITE(TeamID.TWO), 12 GRAY(TeamID.THREE); 13 14 @Serial 15 private static final long serialVersionUID = 132L; // convention: 1 for model, (01 -> 99) for objects 16 private final TeamID teamID; 17 18 /** 19 * Internal constructor of the enum 20 * 21 * @param teamId the team to bind the tower to 22 */ 23 TowerColour(TeamID teamId) { 24 this.teamID = teamId; 25 } 26 27 /** 28 * Get the {@link TowerColour} connected to a {@link TeamID} 29 * 30 * @param tID the {@link TeamID} enum representing a team 31 * @return the {@link TowerColour} bound to a particular {@link TeamID} 32 */ 33 public static TowerColour fromTeamId(TeamID tID) { 34 for (TowerColour e : TowerColour.values()) { 35 if (e.teamID == tID) return e; 36 } 37 throw new RuntimeException(); 38 } 39 40 /** 41 * Get the {@link TeamID} bound to a specific color of the tower 42 * 43 * @return the {@link TeamID} bound to the current {@link TowerColour} variant 44 */ 45 public TeamID getTeamID() { 46 return teamID; 47 } 48 }