SHARE
TWEET

Untitled

advictoriam Feb 1st, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.    Describes a vehicle with a self-contained propulsion unit.
  3. */
  4. public class Vehicle
  5. {
  6.    /*
  7.      TODO: To increase cohesion, reimplement this class by using
  8.      the Propulsion class. Do not modify the main method that is use
  9.      for checking.
  10.    */
  11.  
  12.    private String make;
  13.    private String model;
  14.    private String year;
  15.    private String type;
  16.    private int wheelCount;
  17.    private String engineType;
  18.    private String fuel;
  19.    private Propulsion propulsion;
  20.  
  21.    /**
  22.       Constructs a vehicle
  23.       @param aMake the vehicle's make
  24.       @param aModel the vehicle's model
  25.       @param aType the type of the vehicle
  26.       @param numWheels the number of wheels on this vehicle
  27.       @param aFuel the type of fuel used by this vehicle
  28.    */
  29.    
  30.    public Vehicle(String aMake, String aModel, String aYear,
  31.       String aType, int numWheels, Propulsion p)
  32.    {
  33.       make = aMake;
  34.       model = aModel;
  35.       year = aYear;
  36.       type = aType;
  37.       wheelCount = numWheels;
  38.       propulsion = p;
  39.    }
  40.    
  41.    public static void main(String[] args)
  42.    {
  43.       Vehicle auto = new Vehicle("Ford","Taurus","2010","automobile",
  44.          4,new Propulsion("combustion","gasoline"));
  45.       System.out.println(auto.formatForPrinting());
  46.    }
  47.  
  48.    /**
  49.     * Formats the vehicle information for printing
  50.     * @returns a string sutiable for printing
  51.     */
  52.    public String formatForPrinting()
  53.    {
  54.       return "Make: " + make + "\n"
  55.          + "Model: " + model + "\n"
  56.          + "Year: " + year + "\n"
  57.          + "Type: " + type + "\n"
  58.          + "Number of wheels: " + wheelCount + "\n"
  59.          + propulsion.format();
  60.    }  
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top