diff --git a/src/main/java/it/polimi/ingsw/gc14/Model/Player.java b/src/main/java/it/polimi/ingsw/gc14/Model/Player.java index 00e46b7..62b6e38 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Model/Player.java +++ b/src/main/java/it/polimi/ingsw/gc14/Model/Player.java @@ -5,6 +5,8 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCard; import java.util.ArrayList; +import static java.lang.Math.abs; + public class Player { // Getters private String UserName; @@ -41,7 +43,11 @@ public class Player { // End getters // Setters - public void setUserName(String UserName){ + public void setUserName(String UserName) throws IllegalArgumentException{ + int max_len = 32; + if(UserName.length() > max_len || UserName.length() == 0){ + throw new IllegalArgumentException(); + } this.UserName = UserName; } @@ -57,7 +63,9 @@ public class Player { this.FoodValue += Value; } + // TODO, chiedere prof (throws IllegalArgument) public Boolean removeFood(int Value){ + // Value = abs(Value); chiedere prof if(Value > this.FoodValue){ return false; } @@ -66,12 +74,12 @@ public class Player { } public void addPrestige(int Value){ + this.PrestigeValue += Value; } - // TODO public void removePrestige(int Value){ - // check max/min value (605) + this.PrestigeValue -= Value; } // End setters