1 package edu.berkeley.fleet.two;
2 import edu.berkeley.fleet.api.*;
5 /** A ship in a Fleet; each ship consists of a collection of <tt>Dock</tt>s */
6 public abstract class FleetTwoShip extends Ship {
8 protected final ShipDescription shipDescription;
10 public FleetTwoShip(Fleet fleet, ShipDescription shipDescription) {
12 this.shipDescription = shipDescription;
15 /** returns the type of the ship ("Fetch", "ALU", etc) */
16 public String getType() { return shipDescription.getName(); }
18 public Dock getDock(String s) {
20 if (b.getName().equals(s))
22 throw new RuntimeException("unknown port \""+getType()+"."+s+"\"");
25 public int getOrdinal() {
27 for(Ship s : getFleet()) {
28 if (s==this) return ord;
29 if (s.getType() != null && s.getType().equals(getType())) ord++;
31 throw new RuntimeException("inconsistency: Ship does not belong to its own Fleet!");