05-class.key

Similar documents
자바 프로그래밍

01-OOPConcepts(2).PDF

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

12-file.key

자바GUI실전프로그래밍2_장대원.PDF

5장.key

02 C h a p t e r Java

Microsoft PowerPoint - 04-UDP Programming.ppt

PowerPoint 프레젠테이션

8장.그래픽 프로그래밍

09-interface.key

PowerPoint Presentation

ch09

9장.key

rmi_박준용_final.PDF

비긴쿡-자바 00앞부속

07 자바의 다양한 클래스.key

gnu-lee-oop-kor-lec10-1-chap10

fundamentalOfCommandPattern_calmglow_pattern_jstorm_1.0_f…

untitled

Interstage5 SOAP서비스 설정 가이드

Design Issues

교육자료

<4D F736F F F696E74202D20C1A63233C0E520B1D7B7A1C7C820C7C1B7CEB1D7B7A1B9D628B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Chap12

Microsoft PowerPoint - 14주차 강의자료

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Microsoft PowerPoint - Java7.pptx

PowerPoint Presentation

03-JAVA Syntax(2).PDF

10장.key

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

JAVA PROGRAMMING 실습 08.다형성

<4D F736F F F696E74202D20C1A63138C0E520C0CCBAA5C6AE20C3B3B8AE28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Java ~ Java program: main() class class» public static void main(string args[])» First.java (main class ) /* The first simple program */ public class

ilist.add(new Integer(1))과 같이 사용하지 않고 ilist.add(1)과 같이 사용한 것은 자바 5.0에 추가된 기본 자료형과 해당 객체 자료 형과의 오토박싱/언박싱 기능을 사용한 것으로 오토박싱이란 자바 컴파일러가 객체를 요구하는 곳에 기본 자료형

PowerPoint Presentation

1

PowerPoint Presentation

Java Programing Environment

Java ...

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

PowerPoint Presentation

Something that can be seen, touched or otherwise sensed

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

예제 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

PowerPoint Presentation

JAVA PROGRAMMING 실습 02. 표준 입출력

PowerPoint 프레젠테이션

chap10.PDF

PowerPoint Presentation

PowerPoint Presentation

Microsoft PowerPoint - 2강

Microsoft PowerPoint - ÀÚ¹Ù08Àå-1.ppt

11장.key

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

PowerPoint 프레젠테이션

OOP 소개

MasoJava4_Dongbin.PDF

Spring Data JPA Many To Many 양방향 관계 예제

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

PowerPoint 프레젠테이션

Java

Contents. 1. PMD ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 2. Metrics ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 3. FindBugs ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ 4. ㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍㆍ

PowerPoint Presentation

초보자를 위한 자바 2 21일 완성 - 최신개정판

어댑터뷰

PowerPoint 프레젠테이션

Spring Boot/JDBC JdbcTemplate/CRUD 예제

PowerPoint Presentation

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

강의자료

파일로입출력하기II - 파일출력클래스중에는데이터를일정한형태로출력하는기능을가지고있다. - PrintWriter와 PrintStream을사용해서원하는형태로출력할수있다. - PrintStream은구버전으로가능하면 PrintWriter 클래스를사용한다. PrintWriter

슬라이드 1

<4D F736F F F696E74202D20C1A63236C0E520BED6C7C3B8B428B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63230C0E520BDBAC0AE20C4C4C6F7B3CDC6AE203128B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

@OneToOne(cascade = = "addr_id") private Addr addr; public Emp(String ename, Addr addr) { this.ename = ename; this.a

교육2 ? 그림

JMF3_심빈구.PDF

TEST BANK & SOLUTION

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Connection 8 22 UniSQLConnection / / 9 3 UniSQL OID SET

신림프로그래머_클린코드.key

5-03-Â÷¼¼´ëÀ¥Iš

쉽게 풀어쓴 C 프로그래밍

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

JMF2_심빈구.PDF

PowerPoint Presentation

11 템플릿적용 - Java Program Performance Tuning (김명호기술이사)

* Factory class for query and DML clause creation * tiwe * */ public class JPAQueryFactory implements JPQLQueryFactory private f

Microsoft PowerPoint - Supplement-03-TCP Programming.ppt [호환 모드]

C# Programming Guide - Types

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

I T C o t e n s P r o v i d e r h t t p : / / w w w. h a n b i t b o o k. c o. k r

mytalk

Microsoft Word - java18-1-final-answer.doc

제11장 프로세스와 쓰레드

Network Programming

Microsoft PowerPoint 자바-기본문법(Ch2).pptx

Transcription:

5 :

2 (method) (public) (private) (interface)

5.1 (Method), (public method) (private method) (constructor), 3

4 5.2 (client). (receiver)., System.out.println("Hello"); (client object) (receiver object) println System.out println

5, (ASCII Art),-. _ " _ \_/ 'm' >{ - (_\ /_) ( ) sahr / \ (\ /) ejm97 `-^ hjw /** printbee: */ public void printbee() { System.out.println(",-."); System.out.println(" \\_/"); System.out.println(">{ -"); System.out.println(" / \\"); System.out.println(" `-^");

6 AsciiArtWriter /** AsciiArtWriter */ public class AsciiArtWriter { /** : */ public AsciiArtWriter() // { System.out.println(); /** printbee: */ public void printbee() { System.out.println(",-."); System.out.println(" \\_/"); // : \ \\ System.out.println(">{ -"); System.out.println(" / \\"); System.out.println(" `-^ hjw"); System.out.println(); ( )

7 AsciiArtWriter /** printbutterfly: */ public void printbutterfly() { System.out.println(" _ \""); // : " \" System.out.println(" (_\\ /_)"); System.out.println(" (/ \\) ejm97"); System.out.println(); /** printladybug: */ public void printladybug() { System.out.println(" `m\'"); // : ' \' System.out.println(" ( ) sahr"); System.out.println(); ( )

8 DrawArt /** DrawArt */ public class DrawArt { public static void main(string[] args) { AsciiArtWriter writer = new AsciiArtWriter(); writer.printbee(); System.out.println( This is a test. ); writer.printbutterfly(); writer.printladybug(); printbee, printbutterfly, printladybug

9 DrawArt main println System.out println printbee printbutterfly printladybug AsciiArtWriter printbee printbutterfly printladybug println

10 5.3 (Parameter),. (argument) (actual parameter). (formal parameter)..,.,,.

11 : printbeewithname /** printbeewithname: * @param name ( ) */ public void printbeewithname(string name) { System.out.println(",-."); System.out.println(" \\_/"); System.out.println(">{ - + name + - ); System.out.println(" / \\"); System.out.println(" `-^ System.out.println(); hjw");,-. \_/ >{ -Lucy- / \ `-^ (binding) AsciiArtWriter writer = new AsciiArtWriter(); Writer.printBeeWithName( Lucy );

12 : printinverse #1 import java.text.*; public class MathOperations {... /** printinverse: 1/i, 3 * @param i */ public void printinverse(int i) { DecimalFormat formatter = new DecimalFormat( 0.000 ); double d = 1.0 / i; String s = formatter.format(d); System.out.println(s);... MathOperations calculator = new MathOperations(); calculator.printinverse(3);

13 : printinverse #2 import java.text.*; public class MathOperations {... /** printinverse: 1/i pattern * @param i * @param pattern - */ public void printinverse(int i, String pattern) { DecimalFormat formatter = new DecimalFormat(pattern); double d = 1.0 / i; String s = formatter.format(d); System.out.println(s);... MathOperations calculator = new MathOperations(); calculator.printinverse(3, "0.00000"); calculator.printinverse(5, "0.0");

14 : printinverse #3 import java.text.*; public class MathOperations {... /** printinverse: 1/i pattern * @param i * @param pattern - */ public void printinverse(int i, DecimalFormat f) { double d = 1.0 / i; String s = f.format(d); System.out.println(s);... MathOperations calculator = new MathOperations(); DecimalFormat five_places = new DecimalFormat("0.00000"); calculator.printinverse(3, five_places);

15 printinverse(int i) printinverse(int i, String pattern) printinverse(int i, DecimalFormat f) printinverse(5, "0.00000"); (overloading).

16 5.4 :. < >.writesentence("oukseh Lee");. < >.repositionsentence(50, 80);

17 (specification) class MyWriter: (constructor): MyWriter(int w, int h) (w, h) (private attributes): sentence width, height x_position, y_position (methods): writesentence(string s) s repositionsentence(int x, int y) (x, y)

18 : class MyWriter import java.awt.*; import javax.swing.*; /** MyWriter: */ public class MyWriter extends JPanel { private int width; // private int height; // private String sentence = ""; // private int x_position; // x private int y_position; // y public MyWriter(int w, int h) {... public void paintcomponent(graphics g) {... public void writesentence(string s) {... public void repositionsentence(int x, int y) {...

19 : /** MyWriter * @param w - * @param h - */ public MyWriter(int w, int h) { width = w; height = h; x_position = width / 5; y_position = height / 2; JFrame f = new JFrame(); f.getcontentpane().add(this); f.settitle("mywriter"); f.setsize(width, height); f.setvisible(true); // //

20 : /** paintcomponent: * @param g - */ public void paintcomponent(graphics g) { g.setcolor(color.red); g.drawstring(sentence, x_position, y_position);

21 : /** writesentence: s * @param s - */ public void writesentence(string s) { sentence = s; this.repaint(); /** repositionsentence: (x,y) * @param x - x * @param y - y */ public void repositionsentence(int x, int y) { x_position = x; y_position = y; writesentence(sentence);

22 : MyExample import javax.swing.*; public class MyExample { public static void main(string[] args) { int x = 50; int y = 80; MyWriter w = new MyWriter(300, 200); w.repositionsentence(x, y); String s = JOptionPane.showInputDialog ("Please type some text:"); w.writesentence(s);

5.5 (Function):., int c = new Integer(input).intValue();. : int, char, double, boolean : String, GregorianCalendar, Integer 23

24, class TemperatureConvertor { /** celsiusintofahrenheit: * @param c - (int) * @return (double) */ public double celsiusintofahrenheit(int c) { double f = ((9.0/5.0)*c) + 32; return f; return String input = JOptionPane.showInputDialog( Type an integer Celsius temperature: ); int c = new Integer(input).intValue(); TemperatureConvert convert = new TemperatureConvertor(); double f = convert.celsiusintofahrenheit(c); double f = new TemperatureConvertor().celsiusIntoFahrenheit(c);

return. return. convert.celsiusintofahrenheit(c); 25

5.6 (Private Method), 26

, ver 2.0. makeborder 27

28 : private void makeborder(graphics g) { g.setcolor(color.blue); g.fillrect(0, 0, width, height); // int border_size = 20; int center_rectangle_width = width - (2 * border_size); int center_rectangle_height = height - (2 * border_size); g.setcolor(color.white); // g.fillrect(border_size, border_size, center_rectangle_width, center_rectangle_height); public void paintcomponent(graphics g) { makeborder(g); g.setcolor(color.red); g.drawstring(sentence, x_position, y_position);

,., paintanegg,. 29

30 StackedEggsWriter import java.awt.*; import javax.swing.*; public class StackedEggsWriter extends JPanel { private int frame_width; private int frame_height; // private int egg1_size; private int egg2_size; private int egg3_size; public StackedEggsWriter (int width, int height, int size1, int size2, int size3) {... private int paintanegg(int bottom, int width, Graphics pen) {... public void paintcomponent(graphics g) {... public static void main(string[] args) {...

31 public StackedEggsWriter (int width, int height, int size1, int size2, int size3) { frame_width = width; frame_height = height; egg1_size = size1; egg2_size = size2; egg3_size = size3; JFrame my_frame = new JFrame(); my_frame.getcontentpane().add(this); my_frame.settitle("stackedeggswriter"); my_frame.setsize(frame_width, frame_height); my_frame.setbackground(color.yellow); my_frame.setvisible(true); public static void main(string[] args) { new StackedEggsWriter(300, 200, 50, 90, 140);

32 paintanegg @return bottom /** paintanegg: width*2/3 : bottom : width, 3:2 width * @param bottom - y * @param width - * @param pen - * @return y */ private int paintanegg(int bottom, int width, Graphics pen) { int height = (2 * width) / 3; int top_edge = bottom - height; int left_edge = (frame_width - width) /2; pen.setcolor(color.pink); pen.filloval(left_edge, top_edge, width, height); pen.setcolor(color.black); pen.drawoval(left_edge, top_edge, width, height); return top_edge;

public void paintcomponent(graphics g) { // int egg1_top = paintanegg(frame_height, egg1_size, g); // int egg2_top = paintanegg(egg1_top, egg2_size, g); // paintanegg(egg2_top, egg3_size, g); 33

,,,, : MyWriter, GregorianCalendar : printbee, writesentence,, : answer, left_edge FRAME_WIDTH 34

35 (Static)., Math.abs(f).. class A static int a = ; static void f() {... a...... b...

36 (static):, ( ):, new. class A static int a = ; static void f() {... a...... b... new instance of A int b = ; void f() {... a...... b...

37 vs class A static int a = ; static void f() {... a b...... f() g()... new instance of A int b = ; void g() {... a b...... f() g()... instance of A int b = ; void g() {... a b...... f() g()...

38 final: (8.7, 9 ) abstract: (body) (9 ) synchronized:

39 (method) (public), (private), (static) (parameter)