Merge pull request #9
Add: PlayerTest.java Added Javadoc For "UserName" And "getUserName"
This commit is contained in:
@@ -7,11 +7,27 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCards.Characters.*;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static java.lang.Math.abs;
|
/**
|
||||||
|
* Default Player class; contains all identifiers and methods needed.
|
||||||
|
*/
|
||||||
public class Player {
|
public class Player {
|
||||||
// Getters
|
/**
|
||||||
|
* The maximum length allowed for the username string.
|
||||||
|
*/
|
||||||
|
private static final int MAX_VALUE = 32;
|
||||||
|
|
||||||
|
// region Getters
|
||||||
|
/**
|
||||||
|
* Unique string identifier for players; must not be {@code null} and must not
|
||||||
|
* exceed {@link #MAX_VALUE} otherwise an {@link IllegalArgumentException} will be thrown
|
||||||
|
* when the {@link #Player(String) constructor} is called.
|
||||||
|
*/
|
||||||
private String UserName;
|
private String UserName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for the private attribute {@link #UserName}.
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
public String getUserName() {
|
public String getUserName() {
|
||||||
return UserName;
|
return UserName;
|
||||||
}
|
}
|
||||||
@@ -57,9 +73,9 @@ public class Player {
|
|||||||
* return Game;
|
* return Game;
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
// End getters
|
// endregion getters
|
||||||
|
|
||||||
// Setters
|
// region Setters
|
||||||
public void addFood(int Value){
|
public void addFood(int Value){
|
||||||
this.FoodValue += Value;
|
this.FoodValue += Value;
|
||||||
}
|
}
|
||||||
@@ -81,12 +97,12 @@ public class Player {
|
|||||||
|
|
||||||
this.PrestigeValue -= Value;
|
this.PrestigeValue -= Value;
|
||||||
}
|
}
|
||||||
// End setters
|
// endregion setters
|
||||||
|
|
||||||
// Constructors
|
// region Constructors
|
||||||
public Player(String UserName) throws IllegalArgumentException {
|
public Player(String UserName) throws IllegalArgumentException {
|
||||||
if(UserName.isEmpty() || UserName.length() > 32) {
|
if(UserName.isEmpty() || UserName.length() > MAX_VALUE) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException("UserName is empty or exceeds maximum permitted length.");
|
||||||
}
|
}
|
||||||
this.UserName = UserName;
|
this.UserName = UserName;
|
||||||
|
|
||||||
@@ -101,8 +117,8 @@ public class Player {
|
|||||||
this.FoodValue = 0;
|
this.FoodValue = 0;
|
||||||
this.PrestigeValue = 0;
|
this.PrestigeValue = 0;
|
||||||
}
|
}
|
||||||
// End constructors
|
// endregion constructors
|
||||||
|
|
||||||
// Functions
|
// region Functions
|
||||||
// End functions
|
// endregion functions
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user