Skip to content
Snippets Groups Projects
Commit 0b3a479c authored by Thomas BREIL's avatar Thomas BREIL
Browse files

Change Add and Retrieve money method

parent 98d6d1d4
Branches main
No related tags found
No related merge requests found
......@@ -42,16 +42,14 @@ public abstract class player {
public void removeMoney(int amount) throws IllegalArgumentException {
public void removeMoney(Integer amount) throws IllegalArgumentException {
if (money - amount < 0) {
throw new IllegalArgumentException("Player can't have a negative money!");
}
money = Integer.parseInt(money.toString()) - amount;
money -= amount;
}
public void addMoney(int amount) {
var value = Integer.valueOf(amount);
money = money + (value != null ? value : 0);
public void addMoney(Integer amount) {
money = money + (amount != null ? amount : 0);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment