Coverage Summary for Class: TeamID (it.polimi.ingsw.Model.Enums)
| Class | Class, % | Method, % | Branch, % | Line, % | 
|---|---|---|---|---|
| TeamID | 100% (1/1) | 100% (4/4) | 75% (3/4) | 85,7% (6/7) | 
1 package it.polimi.ingsw.Model.Enums; 2 3 import java.io.Serial; 4 import java.io.Serializable; 5 6 /** 7 * There are only a handful of possible teams in a game. This enumeration represents them 8 */ 9 public enum TeamID implements Serializable { 10 ONE(0), TWO(1), THREE(2); 11 @Serial 12 private static final long serialVersionUID = 137L; // convention: 1 for model, (01 -> 99) for objects 13 private final int teamID; 14 15 /** 16 * Internal constructor of the enum 17 * 18 * @param teamID the id of the team 19 */ 20 TeamID(int teamID) { 21 this.teamID = teamID; 22 } 23 24 /** 25 * Given an integer, find the corresponding team 26 * 27 * @param id the id of the team to enumerate 28 * @return the {@link TeamID} enum variant if the id is between 0 and 3 (excluded), otherwise returns null 29 */ 30 public static TeamID fromInteger(int id) { 31 for (TeamID e : TeamID.values()) { 32 if (e.teamID == id) return e; 33 } 34 return null; 35 } 36 }