/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package inport; import java.util.OptionalInt; /** * * @author topazh_ag */ public class TransportShip extends MovingObject { private double cargoMax; public double getCargoMax() { return cargoMax; } public void setCargoMax(double cargoMax) { this.cargoMax = cargoMax; } public TransportShip(int id, String name, double cargoMax) { super(id, name); this.cargoMax = cargoMax; } public TransportShip() { } @Override public String toString() { String res = getId() + "; " + getName() + "; " + cargoMax; if (getType().isPresent()) { res += "; " + getType().getAsInt(); } return res; } public TransportShip(String s) { super(s); String[] tokens = s.split(";"); cargoMax = Double.parseDouble(tokens[2].trim()); if (tokens.length >= 4) { setType(OptionalInt.of(Integer.parseInt(tokens[3].trim()))); } } }