package ex06; import common.BankService; import common.Money; import java.util.*; public class TestableBankService implements BankService { //boolean creditCalled=false; boolean debitCalled=false; boolean sufficientFunds=false; Hashtable htCredit=new Hashtable(); public boolean wasCreditCalledWith(Money money, String account) { if(htCredit.containsKey(account)){ return htCredit.get(account).equals(money); } return false; // return creditCalled; } public boolean wasDebitCalledWith(Money money, String account) { return debitCalled; } @Override public void credit(Money money, String fromAccount) { //creditCalled=true; htCredit.put(fromAccount, money); //throw new IllegalStateException("not implemented"); } @Override public void debit(Money money, String toAccount) { debitCalled=true; // throw new IllegalStateException("not implemented"); } @Override public Money convert(Money money, String targetCurrency) { if (money.getCurrency().equals(targetCurrency)) return money; return new Money(money.getAmount() / 15, targetCurrency); } @Override public String getAccountCurrency(String account) { return "123".equals(account) ? "EEK" : "EUR"; } void setSufficientFunds(boolean state){ sufficientFunds=state; } @Override public boolean hasSufficientFundsFor(Money requiredAmount) { return sufficientFunds; } }