/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package inport; import java.util.Map; /** * * @author topazh_ag */ public class StorageState { private Object storage; private Cargo cargo; private double cargoState; /** * Get the value of storage * * @return the value of storage */ public Object getStorage() { return storage; } /** * Set the value of storage * * @param storage new value of storage */ public void setStorage(Object storage) { this.storage = storage; } public Cargo getCargo() { return cargo; } public void setCargo(Cargo cargo) { this.cargo = cargo; } /** * Get the value of cargoState * * @return the value of cargoState */ public double getCargoState() { return cargoState; } /** * Set the value of cargoState * * @param cargoState new value of cargoState */ public void setCargoState(double cargoState) { this.cargoState = cargoState; } /** * * @param storage */ public StorageState(Object storage, Cargo cargo, double cargoState) { this.storage = storage; this.cargo = cargo; this.cargoState = cargoState; } public StorageState() { } @Override public String toString() { if (storage instanceof Storage) return cargo.getId() + ";" + ((Storage)storage).getId() + ";" + cargoState; if (storage instanceof TransportShip) return cargo.getId() + ";" + ((TransportShip)storage).getId() + ";" + cargoState; return ""; } public StorageState(String s, Map mp, Map vp, Map cp) { String[] tokens = s.split(";"); int key = Integer.parseInt(tokens[0].trim()); cargo = cp.get(key); key = Integer.parseInt(tokens[1].trim()); if (mp.containsKey(key)) storage = mp.get(key); if (vp.containsKey(key)) storage = vp.get(key); cargoState = Double.parseDouble(tokens[2].trim()); } }