package class3_1_InheritanceVehicles_start; public class Vehicle { public static final int DEFAULT_NORTH_METERS_PER_SEC = 4; /** The vehicle's position */ protected double northMeters; /** The vehicle's speed */ private double northMetersPerSec; /** 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(double northMeters, double northMetersPerSec) { this.northMeters = northMeters; this.northMetersPerSec = northMetersPerSec; } /** * 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(double northMeters) { this(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() { this(0); } public double getNorthMeters() { return northMeters; } void step() { northMeters += northMetersPerSec; } }