https://docs.oracle.com/javase/tutorial/java/concepts/interface.html

public interface Vehicle {
    double getFuelTankCapacityInGallons(); // 연료 탱크의 용량을 반환
    double getGallonsOfGasoline(); // 현재 남아있는 연료량을 반환
}

// 구현 클래스 예시
public class Car implements Vehicle {
    private double fuelTankCapacity;
    private double gallonsOfGasoline;

    public Car(double fuelTankCapacity) {
        this.fuelTankCapacity = fuelTankCapacity;
        this.gallonsOfGasoline = 0;
    }

    @Override
    public double getFuelTankCapacityInGallons() {
        return fuelTankCapacity;
    }

    @Override
    public double getGallonsOfGasoline() {
        return gallonsOfGasoline;
    }

    public void refuel(double gallons) {
        this.gallonsOfGasoline += gallons;
        if (this.gallonsOfGasoline > fuelTankCapacity) {
            this.gallonsOfGasoline = fuelTankCapacity; // 최대 용량을 넘지 않도록 함
        }
    }
}

public interface Shape {
    double area(); // 도형의 면적을 계산하는 메서드
}

public class Square implements Shape {
    private double side;

    public Square(double side) {
        this.side = side;
    }

    @Override
    public double area() {
        return side * side; // 정사각형의 면적 계산
    }
}

public class Rectangle implements Shape {
    private double width;
    private double height;

    public Rectangle(double width, double height) {
        this.width = width;
        this.height = height;
    }

    @Override
    public double area() {
        return width * height; // 직사각형의 면적 계산
    }
}

// 절차적 코드
public class ProceduralExample {
    public static double calculateRectangleArea(double width, double height) {
        return width * height;
    }
}

// 객체 지향 코드
public interface Shape {
    double area(); // 도형의 면적을 계산하는 메서드
}

public class Rectangle implements Shape {
    private double width;
    private double height;

    public Rectangle(double width, double height) {
        this.width = width;
        this.height = height;
    }

    @Override
    public double area() {
        return width * height; // 직사각형의 면적 계산
    }
}