From 1575c1b3537e53b664ddce9a6aa5ee3d56403bd6 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Fri, 10 Dec 2021 21:59:11 +0100 Subject: [PATCH] added javaDoc in Bank.java --- src/ch/zhaw/catan/Bank.java | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/ch/zhaw/catan/Bank.java b/src/ch/zhaw/catan/Bank.java index 7adecac..52bb9eb 100644 --- a/src/ch/zhaw/catan/Bank.java +++ b/src/ch/zhaw/catan/Bank.java @@ -2,19 +2,39 @@ package ch.zhaw.catan; import java.util.HashMap; - +/** + * Bank Class that stores Resources when not being owned by a player, + * and the needed functions to take and give resources to it. + * + * @author Leonardo Brandenberger + */ public class Bank { private final HashMap resources = new HashMap<>(); + /** + * Construct a Bank Object and stores Config Values in own HashMap. + */ public Bank() { resources.putAll(Config.INITIAL_RESOURCE_CARDS_BANK); - } + /** + * Stores a desired resource in desired quantity in the bank. + * + * @param resource the resource type that gets added to the bank + * @param numberOfResources the quantity of resources of the chosen type get added + */ public void storeResourceToBank(Config.Resource resource, int numberOfResources) { resources.put(resource, resources.get(resource) + numberOfResources); } + /** + * Checks if a Resource is available in the quantity desired. and then deducts it from the bank inventory. + * + * @param resource the resource type that has to be deducted + * @param numberOfResources the quantity of the resource that gets deducted from the inventory + * @return true if resources available and deducted false if not enough resources are in the bank + */ public boolean getResourceFromBank(Config.Resource resource, int numberOfResources) { if (resources.get(resource) >= numberOfResources) { Integer newResourceNumber = resources.get(resource) - numberOfResources;