PowerPoint Presentation

Similar documents
PowerPoint Presentation

PowerPoint Presentation

q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2

JAVA PROGRAMMING 실습 08.다형성

PowerPoint Presentation

Design Issues

PowerPoint Presentation

PowerPoint Presentation

PowerPoint Presentation

gnu-lee-oop-kor-lec06-3-chap7

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

JAVA PROGRAMMING 실습 05. 객체의 활용

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

PowerPoint Presentation

쉽게 풀어쓴 C 프로그래밍

PowerPoint Presentation

쉽게 풀어쓴 C 프로그래밍

JAVA PROGRAMMING 실습 02. 표준 입출력

PowerPoint Presentation

Microsoft PowerPoint 장강의노트.ppt

Microsoft PowerPoint - 2강

No Slide Title

제11장 프로세스와 쓰레드

C++ Programming

PowerPoint 프레젠테이션

PowerPoint Presentation

Microsoft PowerPoint - Lect04.pptx

PowerPoint 프레젠테이션

PowerPoint Presentation

No Slide Title

Microsoft PowerPoint - CSharp-10-예외처리

JAVA PROGRAMMING 실습 09. 예외처리

PowerPoint 프레젠테이션

Microsoft Word - EEL2 Lab4.docx

Network Programming

슬라이드 1

Microsoft PowerPoint - Java7.pptx

JAVA PROGRAMMING 실습 05. 객체의 활용

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public

PowerPoint 프레젠테이션

쉽게 풀어쓴 C 프로그래밍

슬라이드 1

10.0pt1height.7depth.3width±â10.0pt1height.7depth.3widthÃÊ10.0pt1height.7depth.3widthÅë10.0pt1height.7depth.3width°è10.0pt1height.7depth.3widthÇÁ10.0pt1height.7depth.3width·Î10.0pt1height.7depth.3width±×10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width¹Ö pt1height.7depth.3widthŬ10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width½º, 10.0pt1height.7depth.3width°´10.0pt1height.7depth.3widthü, 10.0pt1height.7depth.3widthº¯10.0pt1height.7depth.3width¼ö, 10.0pt1height.7depth.3width¸Þ10.0pt1height.7depth.3width¼Ò10.0pt1height.7depth.3widthµå

JAVA PROGRAMMING 실습 07. 상속

Blog

예제 2) Test.java class A intvar= 10; void method() class B extends A intvar= 20; 1"); void method() 2"); void method1() public class Test 3"); args) A

Microsoft PowerPoint - additional08.ppt [호환 모드]

Microsoft PowerPoint - java1 [호환 모드]

PowerPoint Presentation

[ 마이크로프로세서 1] 2 주차 3 차시. 포인터와구조체 2 주차 3 차시포인터와구조체 학습목표 1. C 언어에서가장어려운포인터와구조체를설명할수있다. 2. Call By Value 와 Call By Reference 를구분할수있다. 학습내용 1 : 함수 (Functi

Microsoft PowerPoint - Chapter 6.ppt

(Microsoft PowerPoint - java1-lecture11.ppt [\310\243\310\257 \270\360\265\345])

C++ Programming

자바 프로그래밍

슬라이드 1

(Microsoft PowerPoint - java2-lecture3.ppt [\310\243\310\257 \270\360\265\345])

PowerPoint Template

JVM 메모리구조

소프트웨어공학개론 강의 5: 객체지향개념 최은만동국대학교컴퓨터공학과

Microsoft PowerPoint - chap11

Microsoft PowerPoint - 04_OOConcepts(2010).pptx

Microsoft PowerPoint - 04-UDP Programming.ppt

Cluster management software

PowerPoint Presentation

17장 클래스와 메소드

쉽게 풀어쓴 C 프로그래밍

슬라이드 1

Microsoft PowerPoint - java2 [호환 모드]

유니티 변수-함수.key

PowerPoint 프레젠테이션

5장.key

05-class.key

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

교육자료

(Microsoft Word - \301\337\260\243\260\355\273\347.docx)

PowerPoint 프레젠테이션

C++ 기본문법 정리

PowerPoint Presentation

쉽게 풀어쓴 C 프로그래밍

<4D F736F F F696E74202D2036C0CFC2B05FB0B4C3BCC1F6C7E2C7C1B7CEB1D7B7A1B9D62E707074>

C++ Programming

PowerPoint Template

PowerPoint 프레젠테이션

1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y; public : CPoint(int a

PowerPoint Presentation

Microsoft PowerPoint - C++ 5 .pptx

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++,

제 1 강 희망의 땅, 알고리즘

Microsoft Word - java19-1-midterm-answer.doc

PowerPoint Presentation

PowerPoint Template

PowerPoint Template

쉽게 풀어쓴 C 프로그래밊

PowerPoint 프레젠테이션

Microsoft PowerPoint - additional07.ppt [호환 모드]

쉽게 풀어쓴 C 프로그래밍

PowerPoint 프레젠테이션

Microsoft PowerPoint - 13_UMLCoding(2010).pptx

Microsoft PowerPoint - Chap12-OOP.ppt

비긴쿡-자바 00앞부속

Transcription:

public class SumTest { public static void main(string a1[]) { int a, b, sum; a = Integer.parseInt(a1[0]); b = Integer.parseInt(a1[1]); sum = a + b ; // 두수를더하는부분입니다 System.out.println(" 두수의합은 " + sum + " 입니다 "); 1

학습목표 이장에서는객체지향의 4 대핵심개념에관해학습한다. 객체지향의개요와절차지향과의차이점을학습한다. 클래스와객체를학습한다. 객체의생성과정을예제를통하여학습한다. 상속의개념을예제를통하여학습한다. 캡슐화의개념과예를학습한다. 다형성의개념을학습한다. 2

목차 section 1 객체지향의개요 - 1-1 객체지향이론과역사 - 1-2 객체지향과절치지향 - 1-3 객체지향의장점 section 2 클래스와객체 - 2-1 클래스와객체의구성 - 2-2 객체의생성 section 3 상속 (Inheritance) section 4 캡슐화 (Encapsulation) section 5 메시지 (Message) section 6 다형성 (Polymorphism) 3

1 객체지향의개요 1-1 객체지향이론과역사 객체지향 (Object-Oriented) 이론 - 컴퓨터를통하여실세계와같은환경을흉내 (simulation) 내기위해발전한이론 실세계를구성하는사물의속성과기능 165 page 4

1 객체지향의개요 1-1 객체지향이론과역사 객체지향언어의역사 166 page 5

1 객체지향의개요 1-2 객체지향과절치지향 절차지향언어 - 프로그램의기본단위는절차 (procedure) 또는함수 (function) 로정의 객체지향언어 - 프로그램의기본단위가객체 - 객체는 속성 + 기능 으로구성 6

1 객체지향의개요 1-2 객체지향과절차지향 절차지향과객체지향 167 page 7

1 객체지향의개요 1-3 객체지향의장점 객체지향의장점 - 문제를쉽고자연스럽게프로그램화 ( 모델링 ) 할수있다. - 쉬운프로그램의개발로인한생산성을향상시킬수있다. - 프로그램모듈을재사용할수있다. 8

2 클래스와객체 클래스 - 하나의클래스로부터여러개의객체를생성하기위해사용하는형판 169 page 9

2 클래스와객체 2-1 클래스와객체의구성 객체 - 속성 + 기능 으로구성 - 객체를생성하는클래스역시 속성 + 기능 으로구성 10

2 클래스와객체 2-1 클래스와객체의구성 실습예제 - 다음은성적의평균을구하는클래스를정의한예이다. 일반적으로객체지향에서속성은필드, 데이터, 속성변수, 객체변수등다양한용어를사용하고, 기능은메소드 (method) 라는용어를사용한다. 170 page 11

2 클래스와객체 2-1 클래스와객체의구성 실습예제 자바로작성된클래스의예 AvgTest.java 01 02 03 04 05 06 07 08 09 class Avg { String name; int avg; public String average(int kor, int eng) { avg = (kor+eng)/2; return name+avg; 속성 기능 12

2 클래스와객체 2-2 객체의생성 실체화 (instantiation) - 클래스로부터객체를생성하는과정 - 인스턴스 (instance) 라부름 실습예제 - 위에서작성된평균을구하는클래스로부터객체를생성하는예를살펴보자. - 평균을구하는클래스로부터객체를생성 171 page 13

2 클래스와객체 2-1 클래스와객체의구성 실습예제 AvgTest.java 01 02 03 04 05 06 07 08 09 10 11 12 13 public class AvgTest { public static void main(string[] args) { Avg student1 = new Avg(); Avg student2 = new Avg(); student1.name = " 김철수 "; student2.name = " 김영희 "; String st1_avg = student1.average(70,80); String st2_avg = student2.average(80,90); System.out.println(st1_avg); System.out.println(st2_avg); student1 객체생성 student2 객체생성 생성된객체의속성에서로다른값을저장 14

2 클래스와객체 2-1 클래스와객체의구성 15

3 상속 (Inheritance) 상속 - 기존클래스로부터모든속성과메소드를상속 - 더필요한속성과메소드를추가하여새로운클래스를생성 16

3 상속 (Inheritance) 실습예제 - 앞절에서사용한평균을구하는클래스에총점을구하는방법이추가된클래스를상속을 이용하여작성해보자. 173 page 17

3 상속 (Inheritance) 실습예제 AvgTest1.java 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 class Avg1 { String name; int avg; public String average(int kor, int eng) { avg = (kor+eng)/2; return name+avg; class Avg1Total extends Avg1 { public int total(int kor, int eng) { int score = kor + eng; return score; 상위클래스정의 상위클래스를상속받아하위클래스정의 18

3 상속 (Inheritance) 실습예제 AvgTest1.java 17 18 19 20 21 22 23 24 25 26 27 28 29 30 public class AvgTest1 { public static void main(string[] args) { Avg1Total student1 = new Avg1Total(); Avg1Total student2 = new Avg1Total(); student1.name = " 김철수 "; student2.name = " 김영희 "; String st1_avg = student1.average(70,80); String st2_avg = student2.average(80,90); int st1_total = student1.total(70,80); int st2_total = student2.total(80,90); System.out.println(st1_avg+" 총점 =" + st1_total); System.out.println(st2_avg+" 총점 =" + st2_total); Avg1Total 객체생성 상속받은속성값설정 생성된객체에서정의된메소드호출 19

3 상속 (Inheritance) 20

3 상속 (Inheritance) 클래스의상속은확장 (extend) 의개념을가짐 - 상위클래스의모든것을상속받고추가로더가지는클래스를구성하는것 클래스의계층구조 175 page 21

3 상속 (Inheritance) 클래스계층구조에서의상속 176 page 22

4 캡슐화 (Encapsulation) 캡슐화 - 감기에걸렸을때먹는캡슐약과같은개념 - 캡슐약에는많은성분이포함되어있지만, 단순히감기를낫게해준다고생각 177 page 23

4 캡슐화 (Encapsulation) 캡슐화를통한 정보의은폐 (information hiding) 의장점 - 객체에포함된정보의손상과오용을막을수있다. - 객체내부의조작방법이바뀌어도사용방법은바뀌지않는다. - 데이터가바뀌어도다른객체에영향을주지않아독립성이유지된다. - 처리된결과만사용하므로객체의이식성이좋다. - 객체를부품화할수있어새로운시스템의구성에부품처럼사용할수있다. 178 page 24

4 캡슐화 (Encapsulation) 실습예제 AvgTest2.java 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 class Avg2 { public String name; private int avg; public String average(int kor, int eng) { avg = (kor+eng)/2; return name+avg; public class AvgTest2 { public static void main(string[] args) { Avg2 student1 = new Avg2();... student1.name = " 김철수 "; student1.avg = 100;... 공개되는속성 공개되지않는속성 공개된속성에접근. 오류발생하지않음 공개되지않은속성에접근. 오류발생 25

5 메시지 (Message) 메시지 - 객체에일을시키는행위 객체사이의메시지전달 179 page 26

5 메시지 (Message) 상속된구조에서의메소드탐색 180 page 27

5 메시지 (Message) 실습예제 AvgTest1.java 01 02 03 04 05 06 07 08 09 10 11 12 public class AvgTest1 { public static void main(string[] args) { Avg1Total student1 = new Avg1Total(); Avg1Total student2 = new Avg1Total();... String st1_avg = student1.average(70,80); String st2_avg = student2.average(80,90); int st1_total = student1.total(70,80); int st2_total = student2.total(80,90);... 객체의메소드호출메시지 28

6 다형성 (Polymorphism) 다형성 (Polymorphism) - 객체지향의중요한개념중에하나 - 서로다른객체가동일한메시지에대하여서로다른방법으로응답할수있는기능 29

6 다형성 (Polymorphism) 실습예제 AvgTest3.java 01 02 03 04 05 06 07 08 09 10 11 12 13 14 class Avg3 { public String name; private int avg; public String average(int kor, int eng) { avg = (kor+eng)/2; return name+" 두과목평균 : "+avg; public String average(int kor, int eng, int mat) { avg = (kor+eng+mat)/3; return name+" 세과목평균 : "+avg; 같은이름을가진메소드선언 ( 메소드오버로딩 ) 매개변수가 2 개일때수행 같은이름을가진메소드선언 ( 메소드오버로딩 ) 매개변수가 3 개일때수행 30

6 다형성 (Polymorphism) 실습예제 AvgTest3.java 15 16 17 18 19 20 21 22 23 24 25 26 public class AvgTest3 { public static void main(string[] args) { Avg3 student1 = new Avg3(); Avg3 student2 = new Avg3(); student1.name = " 김철수 "; student2.name = " 김영희 "; String st1_avg = student1.average(70,80); String st2_avg = student2.average(80,90,100); System.out.println(st1_avg); System.out.println(st2_avg); 다른객체, 동일메시지 31

학습정리 객체지향의개요 1 객체지향은실세계의요소들을 속성 + 기능 으로표현한것이다. 2 자바는객체지향언어를대표하는성공한언어이다. 클래스와객체 1 클래스는객체를생성하는형판 (template) 역할을한다. 2 하나의클래스로부터다수개의객체가생성된다. 3 클래스는 속성 + 기능 으로구성된다. 4 클래스로부터객체를생성하는과정을실체화 (instantiation) 라고하며, 객체를인스턴스라부르기도한다. 5 객체지향은절차지향과는달리프로그램의기본단위가객체 ( 속성 + 기능 ) 이다. 32

학습정리 상속 1 상속을이용하여비슷한기능을가진클래스들을계층구조형태로구성할수있다. 2 상속은상위클래스의모든속성과기능을상속받고, 추가로더가지는확장 (extend) 의개념이다. 3 자바에서는하나의클래스만을상위클래스로가질수있다. 즉다중상속을허용하지않는다. 캡슐화 1 캡슐화는꼭필요한내용만보여주고, 불필요한내용을감춘다는개념이다. 2 클래스를작성할때는꼭필요한내용만공개해야한다. 3 클래스를작성할때캡슐화개념을적용하지않으면, 클래스가잘못사용될수있다 4 캡슐화의개념을적용하여정보은폐 (Information hiding) 를달성할수있다. 33

학습정리 메시지 1 생성된객체들사이의상호관계를정의한것이메시지이다. 2 메시지를통하여객체에일을시킨다. 3 메시지는객체이름, 메소드이름, 메소드수행에필요한인자 (argument) 를포함한다. 다형성 1 다형성은다양한변신을의미하는개념이다. 2 다형성은 서로다른객체가동일한메시지에대하여서로다른방법으로응답할수있는기능 을의미한다. 34

35