Coverage Summary for Class: Player (it.polimi.ingsw.view.model)

Class Class, % Method, % Line, %
Player 100% (1/ 1) 100% (7/ 7) 100% (23/ 23)


1 package it.polimi.ingsw.view.model; 2  3 import java.util.ArrayList; 4 import java.util.List; 5  6 /** 7  * Player Data Structure 8  */ 9 public class Player implements RawObj { 10  /** 11  * Username 12  */ 13  private final String username; 14  /** 15  * Player's status 16  */ 17  private final String status; 18  /** 19  * Worker's color 20  */ 21  private final String color; 22  /** 23  * Player's god 24  */ 25  private final String god; 26  /** 27  * Player's remaining workers 28  */ 29  private final int workers; 30  31  /** 32  * Player Constructor 33  * 34  * @param username player username 35  * @param status player status 36  * @param color player color 37  * @param god player god 38  * @param workers player remaining workers 39  */ 40  public Player(String username, String status, String color, String god, int workers) { 41  if (username == null || username.length() == 0) 42  throw new NullPointerException(); 43  this.username = username; 44  this.status = status; 45  this.color = color; 46  this.god = god; 47  this.workers = workers; 48  } 49  50  @Override 51  public List<String> getRawData() { 52  ArrayList<String> toRes = new ArrayList<>(); 53  toRes.add("Username: " + username); 54  if (god != null) 55  toRes.add("God: " + god); 56  if (color != null) 57  toRes.add("Color: " + color); 58  if (status.equals("WIN") || status.equals("LOSE")) 59  toRes.add("Status: " + status); 60  return toRes; 61  } 62  63  /** 64  * Get player's username 65  * 66  * @return player's username 67  */ 68  public String getUsername() { 69  return username; 70  } 71  72  /** 73  * Get player's status 74  * 75  * @return player status 76  */ 77  public String getStatus() { 78  return status; 79  } 80  81  /** 82  * Get player's color 83  * 84  * @return player's color 85  */ 86  public String getColor() { 87  return color; 88  } 89  90  /** 91  * Get player's god 92  * 93  * @return player's god 94  */ 95  public String getGod() { 96  return god; 97  } 98  99  /** 100  * Get player's remaining number of workers 101  * 102  * @return number of remaining workers 103  */ 104  public int getWorkers() { 105  return workers; 106  } 107  108 }