Fix: Player Tests Correclty added
This commit is contained in:
@@ -5,6 +5,8 @@ import it.polimi.ingsw.gc14.Model.Cards.TribeCard;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static java.lang.Math.abs;
|
||||||
|
|
||||||
public class Player {
|
public class Player {
|
||||||
// Getters
|
// Getters
|
||||||
private String UserName;
|
private String UserName;
|
||||||
@@ -41,7 +43,11 @@ public class Player {
|
|||||||
// End getters
|
// End getters
|
||||||
|
|
||||||
// Setters
|
// 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;
|
this.UserName = UserName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +63,9 @@ public class Player {
|
|||||||
this.FoodValue += Value;
|
this.FoodValue += Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO, chiedere prof (throws IllegalArgument)
|
||||||
public Boolean removeFood(int Value){
|
public Boolean removeFood(int Value){
|
||||||
|
// Value = abs(Value); chiedere prof
|
||||||
if(Value > this.FoodValue){
|
if(Value > this.FoodValue){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -66,12 +74,12 @@ public class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addPrestige(int Value){
|
public void addPrestige(int Value){
|
||||||
|
|
||||||
this.PrestigeValue += Value;
|
this.PrestigeValue += Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
public void removePrestige(int Value){
|
public void removePrestige(int Value){
|
||||||
// check max/min value (605)
|
|
||||||
this.PrestigeValue -= Value;
|
this.PrestigeValue -= Value;
|
||||||
}
|
}
|
||||||
// End setters
|
// End setters
|
||||||
|
|||||||
Reference in New Issue
Block a user