package class4_1_SuperVehicles_start;// Dr. Yoder. MSOE. 20 March 2017 public abstract class Vehicle { public static final int DEFAULT_NORTH_METERS_PER_SEC = 4; private String name; /** 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) { // this.name = name; 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); } /** * Create a new car 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; } /** * Step forward the simulation by one second. */ public void step() { northMeters += northMetersPerSec; } /** * Describe the car and its location * Child classes can use finishDescription() for the standard stuff. * @return a string representation of the object. */ public abstract String toString(); /* * @return a string, not starting with space, which starts * "called ..." and which describes the car and its positoin */ protected String finishDescription() { return "called "+name+" at "+northMeters+" meters north"; } /** * Print how to build the vehicle */ public void build() { this.acquireParts(); this.putPartsTogether(); } /** Acquire actual parts needed for whatever concrete vehicle extends this */ public abstract void acquireParts(); public void putPartsTogether() { System.out.println("Put parts together"); } }