Skip to content

Instantly share code, notes, and snippets.

@teramuza
Last active September 19, 2020 17:52
Show Gist options
  • Select an option

  • Save teramuza/5f802d64be9b202fe4dc7e37d904b197 to your computer and use it in GitHub Desktop.

Select an option

Save teramuza/5f802d64be9b202fe4dc7e37d904b197 to your computer and use it in GitHub Desktop.

Revisions

  1. teramuza revised this gist Sep 19, 2020. 2 changed files with 5 additions and 14 deletions.
    12 changes: 4 additions & 8 deletions per2_EngineFunctions.java
    Original file line number Diff line number Diff line change
    @@ -8,22 +8,18 @@ public void setEngine(Engine engine) {
    }

    public void printManufacturer() {
    System.out.println("Manufactured by: "
    + engine.getManufacturer());
    System.out.println("Manufactured by: " + engine.getManufacturer());
    }

    public void printEngineDispacment() {
    System.out.println(engine.getEngineDisplacement()
    + " cc");
    System.out.println(engine.getEngineDisplacement() + " cc");
    }

    public void printFuelType() {
    System.out.println("This engine using "
    + engine.getFuelType() + " fuel");
    System.out.println("This engine using " + engine.getFuelType() + " fuel");
    }

    public void printYearProduction() {
    System.out.println("Production "
    + engine.getYearProduction());
    System.out.println("Production " + engine.getYearProduction());
    }
    }
    7 changes: 1 addition & 6 deletions per2_Mobil.java
    Original file line number Diff line number Diff line change
    @@ -6,12 +6,7 @@ public Mobil (Engine engine) {
    }

    public static void main(String[] args) {
    Engine engine = new Engine(
    "Honda",
    2200,
    "Gasoline",
    2019
    );
    Engine engine = new Engine("Honda", 2200, "Gasoline", 2019);
    Mobil mobil = new Mobil(engine);

    System.out.println("Here are the specifications of your car: ");
  2. teramuza created this gist Sep 19, 2020.
    36 changes: 36 additions & 0 deletions per2_Engine.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    package per2;

    public class Engine {
    private String manufacturer;
    private double engineDisplacement;
    private String fuelType;
    private int yearProduction;

    public Engine (
    String manufacturer,
    double engineDisplacement,
    String fuelType,
    int yearProduction
    ) {
    this.manufacturer = manufacturer;
    this.engineDisplacement = engineDisplacement;
    this.fuelType = fuelType;
    this.yearProduction = yearProduction;
    }

    public String getManufacturer() {
    return manufacturer;
    }

    public double getEngineDisplacement() {
    return engineDisplacement;
    }

    public String getFuelType() {
    return fuelType;
    }

    public int getYearProduction() {
    return yearProduction;
    }
    }
    29 changes: 29 additions & 0 deletions per2_EngineFunctions.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    package per2;

    public class EngineFunctions {
    Engine engine;

    public void setEngine(Engine engine) {
    this.engine = engine;
    }

    public void printManufacturer() {
    System.out.println("Manufactured by: "
    + engine.getManufacturer());
    }

    public void printEngineDispacment() {
    System.out.println(engine.getEngineDisplacement()
    + " cc");
    }

    public void printFuelType() {
    System.out.println("This engine using "
    + engine.getFuelType() + " fuel");
    }

    public void printYearProduction() {
    System.out.println("Production "
    + engine.getYearProduction());
    }
    }
    23 changes: 23 additions & 0 deletions per2_Mobil.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    package per2;

    public class Mobil extends EngineFunctions{
    public Mobil (Engine engine) {
    setEngine(engine);
    }

    public static void main(String[] args) {
    Engine engine = new Engine(
    "Honda",
    2200,
    "Gasoline",
    2019
    );
    Mobil mobil = new Mobil(engine);

    System.out.println("Here are the specifications of your car: ");
    mobil.printManufacturer();
    mobil.printYearProduction();
    mobil.printEngineDispacment();
    mobil.printFuelType();
    }
    }