Consider the Vehicle class below.

Note how this class intermingles two responsibilities: describing a vehicle, and describing the characteristics of its propulsion. The second responsibility is not trivial. We may want to add support for different types of propulsion, with completely different characteristics. For example, we would be ineterestd in the number of propellers for a boat, and not the number of wheels.

Ideally, a Vehicle class should have a single responsibility: to describe a vehicle has some type of self-contained propulsion. A separate Propulsion class should be responsible for the details of managing propulsion characteristics.

Your task is to modify the Vehicle class so that it uses the Propulsion class given below. The main method shows how your modified class should be used.

Complete the following file:

Vehicle.java

/** Describes a vehicle with a self-contained propulsion unit. */ public class Vehicle { /* TODO: To increase cohesion, reimplement this class by using the Propulsion class. Do not modify the main method that is use for checking. */ private String make; private String model; private String year; private String type; private int wheelCount; private String engineType; private String fuel; /** Constructs a vehicle @param aMake the vehicle's make @param aModel the vehicle's model @param aType the type of the vehicle @param numWheels the number of wheels on this vehicle @param aFuel the type of fuel used by this vehicle */ public Vehicle(String aMake, String aModel, String aYear, String aType, int numWheels, String aEngineType, String aFuel) { make = aMake; model = aModel; year = aYear; type = aType; wheelCount = numWheels; engineType = aEngineType; fuel = aFuel; } public static void main(String[] args) { Vehicle auto = new Vehicle("Ford","Taurus","2010","automobile", 4,new Propulsion("combustion","gasoline")); System.out.println(auto.formatForPrinting()); } /** * Formats the vehicle information for printing * @returns a string sutiable for printing */ public String formatForPrinting() { return "Make: " + make + "\n" + "Model: " + model + "\n" + "Year: " + year + "\n" + "Type: " + type + "\n" + "Number of wheels: " + wheelCount + "\n" + "Engine type: " + engineType + "\n" + "Fuel: " + fuel + "\n"; } }

Use the following file:

Propulsion.java

/**
   Describes the characteristics of a vehicle's propulsion
*/

public class Propulsion
{
   private String engineType;
   private String fuel;
   /**
      Constructs a propulsion object
      @param aEngineType the type of engine
      @param aFuel the type of fuel used in this engine
   */
   public Propulsion(String aEngineType, String aFuel)
   {
      engineType = aEngineType;
      fuel = aFuel;
   }
   
   /**
      Formats the propulsion information for printing
      @returns a string sutiable for printing
   */
   public String format()
   {
      return "Engine Type: " + engineType + "\n" +
         "Fuel: " + fuel + "\n";
   }
}