public int getNumDevCards() { return soldier.getQuantity() + monument.getQuantity() + monopoly.getQuantity() + yearOfPlenty.getQuantity() + roadBuild.getQuantity(); }
/** * @param dh * @throws BankException */ public void setDC(DevelopmentHand dh) throws BankException { soldier.setQuantity(dh.getSoldier()); monument.setQuantity(dh.getMonument()); monopoly.setQuantity(dh.getMonopoly()); yearOfPlenty.setQuantity(dh.getYearOfPlenty()); roadBuild.setQuantity(dh.getRoadBuild()); }
/** * returns true if the player possesses the given quantity of the specified development card. * * @param dt is a DevCardType * @param quantity is the number of cards we want to find * @throws BankException * @pre a valid DevCardType and a non-negative quantity * @post returns true if the player has the specified number of the specified type, false * otherwise. */ public boolean hasDC(DevCardType dt, int quantity) throws BankException { int temp = 0; switch (dt) { case SOLDIER: temp = soldier.getQuantity(); break; case MONOPOLY: temp = monopoly.getQuantity(); break; case YEAR_OF_PLENTY: temp = yearOfPlenty.getQuantity(); break; case ROAD_BUILD: temp = roadBuild.getQuantity(); break; case MONUMENT: temp = monument.getQuantity(); break; default: throw new BankException("type does not exist"); } if (temp < quantity) return false; return true; }
/** * @param dh * @throws BankException */ public void modifyDC(DevelopmentHand dh) throws BankException { soldier.modify(dh.getSoldier()); monopoly.modify(dh.getMonopoly()); yearOfPlenty.modify(dh.getYearOfPlenty()); monument.modify(dh.getMonument()); roadBuild.modify(dh.getRoadBuild()); }
/** * returns true if Bank has any DC's, false otherwise. * * @return */ public boolean hasAnyDC() { if (soldier.getQuantity() > 0) return true; if (monument.getQuantity() > 0) return true; if (monopoly.getQuantity() > 0) return true; if (yearOfPlenty.getQuantity() > 0) return true; if (roadBuild.getQuantity() > 0) return true; return false; }
/** * @param card * @throws BankException */ public void addDC(DevCardType card) throws BankException { switch (card) { case SOLDIER: soldier.modify(1); break; case MONOPOLY: monopoly.modify(1); break; case YEAR_OF_PLENTY: yearOfPlenty.modify(1); break; case ROAD_BUILD: roadBuild.modify(1); break; case MONUMENT: monument.modify(1); break; default: throw new BankException("bad type parameter"); } }