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

Class Class, % Method, % Line, %
Player 100% (1/ 1) 100% (10/ 10) 100% (36/ 36)


1 package it.polimi.ingsw.model; 2  3 /** 4  * Class that is used to store general player's information 5  */ 6 public class Player { 7  /** 8  * Player's username 9  */ 10  private final String username; 11  /** 12  * Player's status 13  */ 14  private StatusPlayer status; 15  /** 16  * Player's color 17  */ 18  private Color color; 19  /** 20  * Player's god 21  */ 22  private God god; 23  /** 24  * Player's number of worker to place 25  */ 26  private int workers; 27  28  /** 29  * Create a Player instance with a username 30  * 31  * @param username player's username 32  * @exception NullPointerException if username is null 33  */ 34  public Player(String username) { 35  if (username == null) 36  throw new NullPointerException(); 37  this.username = username; 38  this.status = StatusPlayer.IDLE; 39  workers = 2; 40  } 41  42  /** 43  * Create a Player's instance from a Player instance 44  * 45  * @param player Player's instance 46  * @exception NullPointerException if player is null 47  */ 48  public Player(Player player) { 49  if (player == null) 50  throw new NullPointerException(); 51  this.username = player.username; 52  this.color = player.getColor(); 53  this.god = player.god; 54  this.workers = player.workers; 55  this.status = player.getStatusPlayer(); 56  } 57  58  /** 59  * Set player's status 60  * 61  * @param status status to set 62  * @exception NullPointerException if status is null 63  */ 64  public void setStatusPlayer(StatusPlayer status) { 65  if (status == null) 66  throw new NullPointerException(); 67  this.status = status; 68  } 69  70  /** 71  * Get player's status 72  * 73  * @return player's status 74  */ 75  public StatusPlayer getStatusPlayer() { 76  return status; 77  } 78  79  /** 80  * Set player color 81  * 82  * @param color color to be set 83  * @exception NullPointerException if color is null 84  */ 85  public void setColor(Color color) { 86  if (color == null) 87  throw new NullPointerException(); 88  this.color = color; 89  } 90  91  /** 92  * Get Player's color 93  * 94  * @return player's color 95  */ 96  public Color getColor() { 97  return color; 98  } 99  100  /** 101  * Set player's god 102  * 103  * @param god god to be set 104  * @exception NullPointerException if god is null 105  */ 106  public void setGod(God god) { 107  if (god == null) 108  throw new NullPointerException(); 109  this.god = god; 110  } 111  112  /** 113  * Delete a worker to place 114  * 115  * @return remaining number of workers to place 116  */ 117  public int placeWoker() { 118  if (workers == 0) 119  throw new IllegalAccessError(); 120  workers--; 121  return workers; 122  } 123  124  /** 125  * Get player's god 126  * 127  * @return player's god 128  */ 129  public God getGod() { 130  return god; 131  } 132  133  /** 134  * Get player's username 135  * 136  * @return player's username 137  */ 138  public String getUsername() { 139  return username; 140  } 141 }