목록JAVA/chapter18_interface (4)
WON.dev
Q1. Test01.java 스마트폰 => 전화기 + 컴퓨터 class Phone 필드 : String owner 메소드 : Constructor, sendCall(), receiveCall() interface Computable메소드 : connectInternet(), playApp() class SmartPhone Phone 상속, Computable 구현 Q2. Test02.java interface Providable메소드: sightseeing(), leisure(), food() class KoreaTour메소드 : Providable 구현을 통해생성 class GuamTour메소드 : Providable 구현을 통해생성 class TourGuide필드 : Providable tour 메소..
package org.joonzis.ex; interface Eatable{ void eat();// public abstract void eat(); } class Pig { public void piggy() { System.out.println("다 먹는다!"); } } class Apple extends Pig implements Eatable{ @Override public void eat() { System.out.println("사과는 맛있어"); } } class Banana extends Pig implements Eatable{ @Override public void eat() { System.out.println("맛있으면 바나나"); } } class Computer extends ..
package org.joonzis.ex; interface Shape{ double PI = Math.PI; double calcArea(); void output(); } class Rect implements Shape{ private int width; private int height; public Rect() {} public Rect(int width, int height) { this.width = width; this.height = height; } @Override public double calcArea() { return width * height; } @Override public void output() { System.out.println("너비 : " + width); Sy..
package org.joonzis.ex; interface Animal{ void move();// 자동으로 abstract public void move(); 로 처리된다. void eat(String food); } class Dog implements Animal{ @Override public void move() { System.out.println("개가 달린다."); } @Override public void eat(String food) { System.out.println(food + "먹는다."); } } public class Ex01_Interface { public static void main(String[] args) { //Animal animal = new Animal()..