package storage;

import java.util.HashMap;
import java.util.Map;

public class Funds {
    Map<String, Double> funds = new HashMap<String, Double>();

    public Funds(){}

    public void clearFunds(){ if(funds != null) funds.clear(); }

    public void addFund(String name, double value){
        funds.put(name, value);
    }

    public double getValue(String name){
        return funds.get(name);
    }

    public void takeValue(String name, double value){
        funds.put(name, funds.get(name)-value);
    }

    public void addValue(String name, double value){
        funds.put(name, funds.get(name)+value);
    }

    public String getFundsStringOutput(){
        String returnValue = "";

        for(Map.Entry<String, Double> entry : funds.entrySet()){
            returnValue += entry.getKey()+" : "+entry.getValue()+"  ";
        }

        return returnValue;
    }
}
