Removed tradeWithBank method and modified constructor

This commit is contained in:
Leonardo Brandenberger 2021-12-04 16:33:52 +01:00
parent e23f8bcdde
commit 69e4c7146e
1 changed files with 3 additions and 15 deletions

View File

@ -1,13 +1,14 @@
package ch.zhaw.catan; package ch.zhaw.catan;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
public class Bank { public class Bank {
private Map<Config.Resource, Integer> resources; private HashMap<Config.Resource, Integer> resources;
public Bank(){ public Bank(){
resources = Config.INITIAL_RESOURCE_CARDS_BANK; resources.putAll(Config.INITIAL_RESOURCE_CARDS_BANK);
} }
@ -27,17 +28,4 @@ public class Bank {
return false; return false;
} }
} }
public boolean tradeWithBank(Config.Resource resourceToReceive, Config.Resource resourceToGive, int toWant, int toGive) {
if(resources.get(resourceToReceive) >= toWant){
Integer newResourceReceived = resources.get(resourceToReceive) + toGive;
Integer newResourcesGiven = resources.get(resourceToGive) - toWant;
resources.put(resourceToReceive, newResourceReceived);
resources.put(resourceToGive, newResourcesGiven);
return true;
}
else{
return false;
}
}
} }