/** A fast Ship. Red and going 20 knots by default. * * Taken from Core Web Programming from * Prentice Hall and Sun Microsystems Press, * http://www.corewebprogramming.com/. * © 2001 Marty Hall and Larry Brown; * may be freely used or adapted. */ public class Speedboat extends Ship { private String color = "red"; /** Builds a red Speedboat going N at 20 knots. */ public Speedboat(String name) { super(name); setSpeed(20); } /** Builds a speedboat with specified parameters. */ public Speedboat(double x, double y, double speed, double direction, String name, String color) { super(x, y, speed, direction, name); setColor(color); } /** Report location. Override version from Ship. */ public void printLocation() { System.out.print(getColor().toUpperCase() + " "); super.printLocation(); } /** Gets the Speedboat's color. */ public String getColor() { return(color); } /** Sets the Speedboat's color. */ public void setColor(String colorName) { color = colorName; } }