09-interface.key

Similar documents
01-OOPConcepts(2).PDF

PowerPoint 프레젠테이션

5장.key

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

PowerPoint 프레젠테이션

05-class.key

12-file.key

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

Microsoft PowerPoint - 04-UDP Programming.ppt

rmi_박준용_final.PDF

비긴쿡-자바 00앞부속

02 C h a p t e r Java

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

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

ch09

자바 프로그래밍

쉽게 풀어쓴 C 프로그래밍

1

JMF3_심빈구.PDF

Mobile Service > IAP > Android SDK [ ] IAP SDK TOAST SDK. IAP SDK. Android Studio IDE Android SDK Version (API Level 10). Name Reference V

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

제8장 자바 GUI 프로그래밍 II

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

OOP 소개

PowerPoint Presentation

Microsoft PowerPoint - Java7.pptx

Java Programing Environment

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

03-JAVA Syntax(2).PDF

fundamentalOfCommandPattern_calmglow_pattern_jstorm_1.0_f…

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

10장.key

Modern Javascript

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

11장.key

PowerPoint 프레젠테이션

어댑터뷰

JMF2_심빈구.PDF

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

Spring Boot/JDBC JdbcTemplate/CRUD 예제

Chap12

JUNIT 실습및발표

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

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

Secure Programming Lecture1 : Introduction

C# Programming Guide - Types

Javascript.pages

14-Servlet

MasoJava4_Dongbin.PDF

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

JAVA PROGRAMMING 실습 08.다형성

Microsoft PowerPoint - 2강

03장


10-Java Applet

Java

PowerPoint Presentation

9장.key

04장

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

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

( )부록

Design Issues

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

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

鍮뚮┰硫붾돱??李⑤낯

교육자료

13ÀåÃß°¡ºÐ

강의자료

쉽게 풀어쓴 C 프로그래밍

Microsoft PowerPoint - 14주차 강의자료

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Interstage5 SOAP서비스 설정 가이드

유니티 변수-함수.key

<4D F736F F F696E74202D20C1A63233C0E520B1D7B7A1C7C820C7C1B7CEB1D7B7A1B9D628B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

Microsoft PowerPoint - lec2.ppt

교육2 ? 그림

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µå

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

Java XPath API (한글)

JavaGeneralProgramming.PDF

ThisJava ..

제11장 프로세스와 쓰레드

PowerPoint Presentation

PowerPoint 프레젠테이션

03장.스택.key

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

쉽게 풀어쓴 C 프로그래밊

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

mytalk

C프로-3장c03逞풚

chapter6.doc

PowerPoint Presentation

DocsPin_Korean.pages

A Tour of Java IV

자바로

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

rosaec_workshop_talk

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

Transcription:

9

Database insert(record r): boolean find(key k): Record 1 Record getkey(): Key * Record Key Database.? Key equals(key y): boolean

Database insert(record r): boolean find(key k): Record * Database OK 1 Record getkey(): Key Key equals(key y): boolean Record1 Key id; String name; getkey(): Key; Record2 Key code; String title; boolean is_borrowed; getkey(): Key; Key1 private int no; equals(key1 y): Key2 string category; private int no; equals(key2 y):

Record1 Key id; String name; getkey(): Key; Java (interface).. Record getkey(): Key Record2 Key code; String title; boolean is_borrowed; getkey(): Key; Java Record.,.

interface < > { < >,,,. interface Key { boolean equals(key y); interface Record { Key getkey();

.,, new.., Key k;, void method (Key k) {..., Key getkey() {...

implements < >. class IntegerKey implements Key { private int key; public IntegerKey(int i) { key = i; public int getint() { return key; Key equals boolean equals(key k) { return key == ((IntegerKey)k).getInt();

. class CodeKey implements Key { private String category; private int code; public CodeKey(String s, int i) { category=s; code=i; public String getcategory() { return category; public int getcode() { return code; Key equals boolean equals(key k) { CodeKey ck = (CodeKey) k; return category.equals(ck.getcategory()) && code == ck.getint();

IntegerKey, CodeKey Key. class findlocationdatabase {... private int findlocation(key k) { for (int i=0; i<base.length; i++) if(base[i]=null && k.equals(base[i].getkey())) return i; return NOT_FOUND;...

,,,,??. : * *

: + +

CSE216 프로그램 설계 방법론 인터페이스 구현: 요구조건만 만족 인공지능 로봇: * 대화 * 장애물을 피하면서 이동 로봇 제작설명서 로봇 제작설명서 로봇 제작설명서 인터페이스 로봇 제작설명서 한양대학교 ERICA 컴퓨터공학과

vs. class B extends A class B implements A A x = new B();,.

,.......

public interface RoomBehaviour { public boolean enter(playerbehaviour p); public void exit(playerbehaviour p); public PlayerBehaviour occupantof(); public interface PlayerBehaviour { public String speak(); public boolean explore(roombehaviour r);

public class BasicRoom implements RoomBehaviour { private PlayerBehaviour occupant; private String rooms_name; private String secret_word; public BasicRoom(String name, String password) { occupant = null; rooms_name = name; secret_word = password; public boolean enter(playerbehaviour p) { boolean result = false; if(occupant == null && secret_word.equals(p.speak())) { occupant = p; result = true; return result; public void exit(playerbehaviour p) { if(occupant == p) occupant = null; public PlayerBehaviour occupantof() { return occupant;

public class Explorer implements PlayerBehaviour { private String name, secret_word; private RoomBehaviour where_i_am; public Explorer(String n, String w) { name = n; secret_word = w; where_i_am = null; public String speak() { return secret_word; public void exitroom() { if(where_i_am = null) { where_i_am.exit(this); where_i_am = null; public boolean explore(roombehaviour r) { if(where_i_am = null) exitroom(); boolean went_inside = r.enter(this); if(went_inside) where_i_am = r; return went_inside; public RoomBehaviour locationof() { return where_i_am;

RoomBehaviour[] ground_floor = new RoomBehaviour[4]; ground_floor[0] = new BasicRoom("kitchen", "pasta"); ground_floor[3] = new BasicRoom("lounge", "swordfish"); Explorer harpo = new Explorer("Harpo Marx", "swordfish"); Explorer chico = new Explorer("Chico Marx", "tomato"); boolean success = harpo.explore(ground_floor[3]);

.. public interface TreasureProperty { public String contentsof(); public interface TreasuryRoomBehaviour { public boolean enter(playerbehaviour p); public void exit(playerbehaviour p); public TreasureProperty yieldtreasure(playerbehaviour p); public PlayerBehaviour occupantof();

: public interface RoomBehaviour { public boolean enter(playerbehaviour p); public void exit(playerbehaviour p); public PlayerBehaviour occupantof(); public interface Treasury { public TreasureProperty yieldtreasure(playerbehaviour p); public class VaultRoom implements Treasury, RoomBehaviour { //...

: public interface RoomBehaviour { public boolean enter(playerbehaviour p); public void exit(playerbehaviour p); public PlayerBehaviour occupantof(); public interface TreasuryRoomBehaviour extends RoomBehaviour { public TreasureProperty yieldtreasure(playerbehaviour p); public class VaultRoom implements TreasuryRoomBehaviour { //...

interface RoomBehaviour interface Treasury interface RoomBehaviour interface TreasuryRoomBehaviour class VaultRoom class VaultRoom

,? interface Treasury interface RoomBehaviour interface TreasuryRoomBehaviour public interface TreasuryRoomBehaviour extends Treasury, RoomBehaviour { public class VaultRoom implements TreasuryRoomBehaviour { //... class VaultRoom

? interface Treasury class Golden interface RoomBehaviour class BasicRoom (multiple inheritance). Java. class VaultRoom

,

,. m(b x) {... m(c x) {... m(d x) {...... m(a x) {..., B, C, D A, A

(Subtype)., < < < < <,.

. ===> ==>. ==> ==>

Java class B extends A class B implements A B < A? a.method(); b.method(); b.method(); a.method();

A x = y; y B A B OK. void m(a x) m(y) y x., y B A B OK.

? B < A B[]?? A[] A[] arr = new B[]; a[0] = new A(); (X) B[] > A[], Java B[] < A[]

IntegerKey, CodeKey Key. class findlocationdatabase {... private int findlocation(key k) { for (int i=0; i<base.length; i++) if(base[i]=null && k.equals(base[i].getkey())) return i; return NOT_FOUND;...

interface Key {. boolean equals(key y); class IntegerKey implements Key { private int key; public IntegerKey(int i) { key = i; public int getint() { return key; boolean equals(key k) { return key == ((IntegerKey)k).getInt();... boolean equals(integerkey k)?

Key interface Key { boolean equals(key y); class IntegerKey implements Key {... boolean equals(key k) {... equals Key. return key == ((IntegerKey)k).getInt(); Key k IntegerKey k Key k Key y Key,, IntegerKey IntegerKey y, CodeKey CodeKey y.

. boolean equals(key k) {... (IntegerKey) k... IntegerKey ik; CodeKey ck; ik.equals(ck);? if(k instanceof IntegerKey) {... (IntegerKey) k... else {

, IntegerKey.equals interface Key { boolean equals(key y); class IntegerKey implements Key {... boolean equals(key k) { if(k instanceof IntegerKey) return key == ((IntegerKey)k).getInt(); else return false;...

(Generic) Key, Key equals. Key<T> T equals. Key<T extends Key<T>> Key<T> T equals. class IntegerKey implements Key<IntegerKey> {... IntegerKey.

, IntegerKey.equals interface Key <T extends Key<T>> { boolean equals(t y); class IntegerKey implements Key <IntegerKey> {... boolean equals(integerkey k) { return key == k.getint();

Database public interface Key <T extends Key<T>>{ boolean equals(t k); public interface Record <K extends Key<K>>{ K getkey(); public class Database <K extends Key<K>, R extends Record<K>>{ private R[] base;... public Database (int initial_size) {... private int findlocation(k k) {... private int findempty() {... public R find(k k) {... public boolean delete(k k) {... public boolean insert(r r) {... : new R[10] (R[]) new Record[10]

(Abstract Class), ==> ==>

, class Card class CardDeck class Dealer,. interface CardPlayerBehaviour interface public interface CardPlayerBehaviour { public boolean wantsacard(); public void receivecard(card c);

,..,?.. " " CardPlayer.

public abstract class CardPlayer implements CardPlayerBehaviour { private Card[] my_hand; private int card_count; public CardPlayer(int max_cards) { my_hand = new Card[max_cards]; card_count = 0; public abstract boolean wantsacard(); public void receivecard(card c) { my_hand[card_count] = c; card_count = card_count + 1;

import javax.swing.*; public class HumanPlayer extends CardPlayer { public HumanPlayer(int max_cards) { super(max_cards); public boolean wantsacard() { String response = JOptionPane.showInputDialog ("Do you want another card (Y or N)?"); return response.equals("y");. CardPlayer(). super CardPlayer(max_cards).

public class ComputerPlayer extends CardPlayer { public ComputerPlayer(int max_cards) { super(max_cards); public boolean wantsacard() { int sum = 0; for(int i=0; i<card_count; i++) sum += my_hand[i].getcount(); return sum < 15;

Dealer CardPlayerBehavior wantsacard(): boolean receivecard(card c) CardPlayer wantsacard(): boolean receivecard(card c) HumanPlayer wantsacard(): boolean ComputerPlayer wantsacard(): boolean

public abstract class Animal { // public abstract class WarmBlooded extends Animal { // public abstract class Equine extends WarmBlooded { // public class Horse extends Equine { //

Form Point Line Straight Jagged Curved Shape Curved Circle Ellipse Polygon Triangle Rectangle

(Framework)., GraphicsWindow setsize, setbackground, setvisible paint paint Java.

vs,,.,.. Interfaces list behaviours abstract classes list codings

OK,.,?. Java Object. Object.,.

Object Object[] a = new Object[10]; 10 a[0] = new Integer(10); a[1] = "abc";, a[1]? int arraysize(object[] a) { return a.length;...arraysize(new int[10]);...arraysize(new String[5]);, a[1]?

. Object[] a = new Object[10]; a[0] = new Integer(25); System.out.println(a[0].getInteger() / 10); //. a[0] Object // getinteger. System.out.println(((Integer)a[0]).getInteger() / 10); //. System.out.println(a[0]); //.? Object tostring() //.

(Package),., java.util, java.awt, javax.swing import.,.

Java. : ( ) ( ) :,. Java,,. Object.