Removed tradeWithBank method and modified constructor
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
package ch.zhaw.catan;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Bank {
|
||||
private Map<Config.Resource, Integer> resources;
|
||||
private HashMap<Config.Resource, Integer> resources;
|
||||
|
||||
public Bank(){
|
||||
resources = Config.INITIAL_RESOURCE_CARDS_BANK;
|
||||
resources.putAll(Config.INITIAL_RESOURCE_CARDS_BANK);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,17 +28,4 @@ public class Bank {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user