/** More multiple inheritance.
 * @author Jaanus
 * @since 1.8
 */
public class J8example8 {

  public static void main (String[] args) {
    Amphibian a = new Amphibian();
    a.makeNoise();
    a.drive();
    a.enjoyCar();
    a.enjoyBoat();
    Volvo v = new Volvo();
    v.makeNoise();
    v.drive();
    v.enjoyCar();
  }

  @FunctionalInterface
  interface Car {
    public void makeNoise(); // the one and only compulsory method

    default void enjoyCar() {
      System.out.println ("I enjoy my car: Car interface default");
    }

    default void drive() {
      System.out.println ("I drive my car: Car interface default");
    }
  }
   
  @FunctionalInterface
  interface Boat {
    public void makeNoise(); // the one and only compulsory method

    default void enjoyBoat() {
      System.out.println ("I enjoy my boat: Boat interface default");
    }

    default void drive() {
      System.out.println ("I drive my boat: Boat interface default");
    }
  }

  static class Amphibian implements Car, Boat {
    @Override
    public void makeNoise() { // my obligation from both interfaces
      System.out.println ("makeNoise: compulsory from Amphibian class");
    }

    @Override
    public void drive() { // diamond problem solved in Java way
      System.out.println ("I drive my amphibian: from Amphibian class");
    }
  }

  static class Volvo implements Car {
    @Override
    public void makeNoise() { // my obligation from Car interface
      System.out.println ("makeNoise: compulsory from Volvo class");
    }
    
    @Override
    public void enjoyCar() {  // no obligation, just wish to override
      System.out.println ("I enjoy my volvo: override from Volvo class");
    }
  }
}

