인터페이스 이해하고 외우는 중

JAEWOONG LEE·2026년 5월 28일
post-thumbnail

인터페이스쪽에선 public이 자동이다, 그러니 코딩할 필요 없다.

Cooker cooker;
cooker = new Fan();

    Cook_now cook_now = new Cook_now(cooker);

    cook_now.Food_Complete();
    
    이 부분이 헷갈리지만 내일 안에 완성하겠다.
    
    빌더부분을 배웠는데 내일 오전안에 인터이스 마저 작성 후 빌더쪽도 이해해버리겠다.
    
    오늘은 1차 상담한 날이며 

package oop4practice.eg09testMyself;

interface Cooker
{
void Cooking();
}

class Fan implements Cooker
{
public void Cooking()
{
System.out.println("Fry");
}
}

class Bowl implements Cooker
{
public void Cooking()
{
System.out.println("Mix");
}
}

class Oven implements Cooker
{
public void Cooking()
{
System.out.println("Bake");
}
}

class Cook_now
{
Cooker cooker;
public Cook_now(Cooker cooker)
{
this.cooker = cooker;
}

public void Food_Complete()
{  
    System.out.println("요리 완성");
    cooker.Cooking();
}

}

public class Main
{
public static void main(String[] args)
{
Cooker cooker;
cooker = new Fan();

    Cook_now cook_now = new Cook_now(cooker);

    cook_now.Food_Complete();

}

}

profile
just for programming test

0개의 댓글