package chapter20230825.test06;
public class Test {
public static void main(String[] args) {
MyCalculator myCalculator = new MyCalculator();
myCalculator.num1 = 10;
myCalculator.num2 = 20;
myCalculator.printResult();
}
}
package chapter20230825.test06;
public class MyCalculator extends Calculator {
@Override
int calc() {
return num1 + num2;
}
}
package chapter20230825.test06;
public abstract class Calculator {
int num1, num2;
abstract int calc();
void printResult() {
System.out.println("연산의 결과는 " + calc() + " 입니다");
}
}