More actions
({CREATE}) |
No edit summary |
||
| (9 intermediate revisions by 2 users not shown) | |||
| Line 38: | Line 38: | ||
= 코드 = | = 코드 = | ||
== 예제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; | |||
} | |||
} | |||
= 숙제 = | = 숙제 = | ||
# 회고 작성 | # 회고 작성 | ||
# 클래스 sciCalc 에 기능 하나 추가해보기 | |||
= 회고록 = | = 회고록 = | ||
'''권재민''' | '''권재민''' | ||
* 난이도: /10 | * 난이도: 6/10 | ||
* 후기: | * 후기: 잘 활용할 자신은 아직 없지만 개념 이해는 잘 되었어요 | ||
---- | ---- | ||
'''이수은''' | '''이수은''' | ||
* 난이도: /10 | * 난이도: 5/10 | ||
* 후기: | * 후기: 어렵지 않게 차근차근 설명해 주셔서 좋았다. | ||
---- | ---- | ||
'''김민경''' | '''김민경''' | ||
* 난이도: /10 | * 난이도: 7/10 | ||
* 후기: | * 후기: 좀 어려운 내용을 쉽게 예시를 들어서 설명해주셔서 이해에 도움이 됐어요 | ||
---- | ---- | ||
'''강필중''' | '''강필중''' | ||
* 난이도: /10 | * 난이도: 7/10 | ||
* 후기: | * 후기: 계산기라는 주제로 얘기해가며 수업하니까 집중이 잘 된 것 같아요. | ||
---- | ---- | ||
'''이길상''' | '''이길상''' | ||
| Line 71: | Line 209: | ||
내용 | 내용 | ||
== 김민경 == | == 김민경 == | ||
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; | |||
} | |||
} | |||
== 강필중 == | == 강필중 == | ||
내용 | 내용 | ||
Latest revision as of 11:33, 3 May 2021
참여자 명단
| 단장 | 이길상 | 16학번 | - |
| 단원 | 강필중 | 21학번 | - |
| 권재민 | - | ||
| 김민경 | - | ||
| 이수은 | - |
수업
진행
- 장소 : 구글 미츠
- 시간 : 19시 ~ 21시
내용
주제
- 상속
ppt
- [[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;
}
}
숙제
- 회고 작성
- 클래스 sciCalc 에 기능 하나 추가해보기
회고록
권재민
- 난이도: 6/10
- 후기: 잘 활용할 자신은 아직 없지만 개념 이해는 잘 되었어요
이수은
- 난이도: 5/10
- 후기: 어렵지 않게 차근차근 설명해 주셔서 좋았다.
김민경
- 난이도: 7/10
- 후기: 좀 어려운 내용을 쉽게 예시를 들어서 설명해주셔서 이해에 도움이 됐어요
강필중
- 난이도: 7/10
- 후기: 계산기라는 주제로 얘기해가며 수업하니까 집중이 잘 된 것 같아요.
이길상
- 후기:
숙제 제출
권재민
내용
이수은
내용
김민경
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;
}
}
강필중
내용