package class3_2_InheritanceVehicles_start; public abstract class Vehicle { public static final int DEFAULT_NORTH_METERS_PER_SEC = 4; /** The vehicle's position */ private double northMeters; /** The vehicle's speed */ private double northMetersPerSec; private String name; /** Create a vehicle at the specied position with the specified initial velocity * * @param northMeters position north of game center of vehicle's center of mass * @param northMetersPerSec velocity north of game center of vehicle's * center of mass, in m/s. */ public Vehicle(String name, double northMeters, double northMetersPerSec) { this.northMeters = northMeters; this.northMetersPerSec = northMetersPerSec; this.name = name; } /** * Create a vehicle at the specified position. * The vehicle will be moving north by default at about 10mph * @param northMeters position north of game center of vehicle's center of mass */ public Vehicle(String name, double northMeters) { this(name, northMeters, DEFAULT_NORTH_METERS_PER_SEC); } /** * Create a new vehicle located at the game center. * The vehicle will be moving north by default at about 10mph. */ public Vehicle(String name) { this(name, 0); } public double getNorthMeters() { return northMeters; } public String getName() {return name;} void step() { northMeters += northMetersPerSec; } public String toString() { return name + " at "+ northMeters +" meters north"; } }