Fix: Player Tests Correclty added

This commit is contained in:
GabrieleRadice
2026-03-14 21:12:54 +01:00
parent 2bb4c00f85
commit b9c2754998
@@ -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