/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package inport; import inport.ConversionUtils.Pair; import java.util.ArrayList; import java.util.Map; import java.util.OptionalInt; /** * * @author topazh_ag */ public class TransportShip extends MovingObject { private ArrayList> storageSections = new ArrayList<>(); public ArrayList> getStorageSections() { return storageSections; } public void setStorageSections(ArrayList> storageSections) { this.storageSections = storageSections; } public TransportShip(int id, String name, ArrayList> storageSections) { super(id, name); this.storageSections = storageSections; } public TransportShip() { } @Override public String toString() { String res = getId() + "; " + getName() + "; " + Storage.storageSectionsToString(storageSections); if (getType().isPresent()) { res += "; " + getType().getAsInt(); } return res; } public TransportShip(String s, Map cargoes) { super(s); String[] tokens = s.split(";"); storageSections = Storage.storageSectionsFromString(tokens[2], cargoes); if (tokens.length >= 4) { setType(OptionalInt.of(Integer.parseInt(tokens[3].trim()))); } } }