Methods for assets avail

This commit is contained in:
7u83 2018-12-28 11:39:15 +01:00
parent 3cc7940658
commit ac22bc0870

View File

@ -32,9 +32,11 @@ import org.json.JSONObject;
/** /**
* Class to hold account data of traders * Class to hold account data of traders
*
* @author 7u83 <7u83@mail.ru> * @author 7u83 <7u83@mail.ru>
*/ */
public class Account { public class Account {
HashMap<AbstractAsset, Double> assets = new HashMap<>(); HashMap<AbstractAsset, Double> assets = new HashMap<>();
HashMap<AbstractAsset, Double> assets_avail = new HashMap<>(); HashMap<AbstractAsset, Double> assets_avail = new HashMap<>();
@ -45,6 +47,10 @@ public class Account {
return Collections.unmodifiableMap(assets); return Collections.unmodifiableMap(assets);
} }
public Map<AbstractAsset, Double> getAssetsAavail() {
return Collections.unmodifiableMap(assets_avail);
}
public Trader getOwner() { public Trader getOwner() {
return owner; return owner;
} }
@ -63,11 +69,14 @@ public class Account {
void add(AssetPack pack) { void add(AssetPack pack) {
assets.put(pack.asset, get(pack.asset) + pack.volume); assets.put(pack.asset, get(pack.asset) + pack.volume);
assets_avail.put( pack.asset, get(pack.asset)+pack.volume); assets_avail.put(pack.asset, getAvail(pack.asset) + pack.volume);
} }
public double get(AbstractAsset asset) { public double get(AbstractAsset asset) {
return assets.getOrDefault(asset, 0.0); return assets.getOrDefault(asset, 0.0);
} }
public double getAvail(AbstractAsset asset) {
return assets_avail.getOrDefault(asset, 0.0);
}
} }