package day0407;
class Calculator {
int left, right;
public void setOprands(int left, int right) {
this.left = left;
this.right = right;
}
public void sum() {
System.out.println(this.left + this.right);
}
public void avg() {
System.out.println((this.left + this.right) / 2);
}
}
// 뺄셈을 할 수 있는 계산기/ 확장한 / Calculator의 기능을 - 클래스 다이어그램 (SublstractionableCalculator는 Calcultor를 상속/확장한다라고 표현)
class SubstractionableCalculator extends Calculator {
public void substract() {
System.out.println(this.left - this.right);
}
}
public class CalculatorDemo01 {
public static void main(String[] args) {
SubstractionableCalculator c1 = new SubstractionableCalculator(); //클래스를 인스턴스화
c1.setOprands(10, 20);
c1.sum();
c1.avg();
c1.substract();
}
}