3.1. 예제1 ¶
public class App3 {
    public static void main(String[] args) {
        // Win + R -> calc
        SciCalc scicalc = new SciCalc();
        int i = scicalc.square(3);
        System.out.println(i);
        Calc calc = new Calc();
        i = calc.add(1,2);
        System.out.println(i);    
        //calc.square();  실행안됨
        ProgCalc progcalc = new ProgCalc();
        i = progcalc.sub(2,1);
        System.out.println(i);
        System.out.println();
        // 'Ctrl + /'
        calc.sub(4,2);
        scicalc.add(1,5);
        progcalc.add(4,4);
        // System.out.println(calc.recent);
        // System.out.println(scicalc.recent);
        // System.out.println(progcalc.recent);
        // SciCalcMk2 scicalcmk2 = new SciCalcMk2();
        // i = scicalcmk2.add(3,5);
        // System.out.println(i);
        // i = scicalcmk2.square(5);
        // System.out.println(i);
        progcalc.add(4, 3.5f);
        calc.recent(0);
        scicalc.recent(0);
        progcalc.recent(0);
        calc.recent(1);
        scicalc.recent(1);
        progcalc.recent(1);
        System.out.println(calc.numbering);
        System.out.println(scicalc.numbering);
    }
}
// Scientific Calculator is Calculator.
// Calculator has Memory
// Calc --> count = 2
// SciCalc --> count = 2
// Calc calc = new Calc()
// SciCalc scicalc = new SciCalc()
class Calc { //<-- 클래스
    static int count =0;
    int numbering;
    Calc(){
        count++;
        numbering = count;
    }
    // int recent = -1;
    Memory memory = new Memory();
    int add(int a, int b){
        String s = "" + a + "+" + b + "=" + (a+b);
        memory.update(s);
        return a+b;
    }
    // Overload 
    float add(float a, float b){
        String s = "" + a + " + " + b + " = " + (a+b);
        memory.update(s);
        return a + b;
    }
    int sub(int a, int b){
        String s = "" + a + "-" + b + "=" + (a-b);
        memory.update(s);
        return a-b;
    }
    void recent(int i){
        System.out.println(memory.recent[i]);
    }
}
class SciCalc extends Calc{
    int square(int a){
        String s = "" + a + "^2=" + (a*a);
        memory.update(s);
        return a*a;
    }
}
class SciCalcMk2 extends SciCalc{
}
class ProgCalc extends Calc{
    // Override
    @Override
    int add(int a, int b){
        String s = "" + a + " 더하기 " + b + " 는" + (a+b);
        memory.update(s);
        return a+b;
    }
    // Overload
    float add(int a ,float b){
        String s = "" + a + " 더하기 " + b + " 는" + (a+b);
        memory.update(s);
        return a+b;
    }
}
// 5, 3, 4
// 6
// 6, 5, 3
class Memory {
    String[] recent = new String[3];
    
    void update(String s){
        recent[2] = recent[1];
        recent[1] = recent[0];
        recent[0] = s;
    }
}
5. 회고록 ¶
권재민
- 난이도: 6/10
 - 후기: 잘 활용할 자신은 아직 없지만 개념 이해는 잘 되었어요
 
이수은
- 난이도: 5/10
 - 후기: 어렵지 않게 차근차근 설명해 주셔서 좋았다.
 
김민경
- 난이도: 7/10
 - 후기: 좀 어려운 내용을 쉽게 예시를 들어서 설명해주셔서 이해에 도움이 됐어요 
 
강필중
- 난이도: 7/10
 - 후기: 계산기라는 주제로 얘기해가며 수업하니까 집중이 잘 된 것 같아요.
 
이길상
- 후기: 
 
6.3. 김민경 ¶
class Calc {
    static int count = 0;
    int numbering = 0;
    Calc(){
        count++;
        numbering = count;
    }
    
    Memory memory = new Memory();
    int add(int a, int b){
        String s = "" +a+ "+" + b + "=" + (a+b);
        memory.update(s);
        return a+b;
    }
    float add(float a, float b){
        String s = ""+ a + "+" + b + "=" + (a+b);
        memory.update(s);
        return a+b;
    }
    int sub(int a, int b){
        String s = "" +a+ "-" + b + "=" + (a-b);
        memory.update(s);
        return a-b;
    }
    void recent(int i){
        System.out.println(memory.recent[i]);
    }
}
class SciCalc extends Calc{
    Calc calc = new Calc();
    int mod(int a, int b){
        String s = " " + a + "mod" + b + " = " + (a%b);
        memory.update(s);
         return a%b;
     }
}










