package class3_1_InheritanceVehicles_start; public class Vehicle { public static final int DEFAULT_NORTH_METERS_PER_SEC = 4; /** The car's position */ private double northMeters; /** The car's speed */ private double northMetersPerSec; /** Create a car 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) { System.out.println("Vehicle(double,double): Constructing a vehicle at " +northMeters+ " m N going " + northMetersPerSec + " m/s"); this.northMeters = northMeters; this.northMetersPerSec = northMetersPerSec; } /** * Create a car 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); System.out.println("Vehicle(double): Constructing a vehicle at " +northMeters+ " m N"); } public double getNorthMeters() { return northMeters; } /** * Step forward the simulation by one second. */ public void step() { northMeters += northMetersPerSec; } @Override public String toString() { return "A vehicle at "+northMeters+ " meters north"; } }