1 package edu.berkeley.fleet.api;
4 /** A ship in a Fleet; each ship consists of a collection of <tt>Dock</tt>s */
5 public abstract class Ship implements Iterable<Dock> {
7 private final Fleet fleet;
9 public Ship(Fleet fleet) {
13 /** return the Fleet that this Ship belongs to */
14 public Fleet getFleet() { return fleet; }
16 /** returns the type of the ship ("Fetch", "Alu", etc) */
17 public abstract String getType();
19 public abstract Iterator<Dock> iterator();
21 /** returns the dock on this ship having name "name" */
22 public abstract Dock getDock(String name);
24 /** the docks of a given type are numbered; this returns the ordinal number of this dock */
25 public abstract int getOrdinal();
27 /** get a constant associated with a ship; returns null if none found */
28 public BitVector getConstant(String constantName) {
29 throw new RuntimeException("unknown constant \""+constantName+"\" on ship " + this);
32 public String toString() {
33 String name = getType();
34 name = name.substring(0,1).toLowerCase()+name.substring(1);
35 return name + "" + getOrdinal() + "";