BIG
package chapter08;
public class StarBugs {
public static void main(String[] args) {
// TODO Auto-generated method stub
Coffee_default mCoffee = new ice_coffee( 3000, 3 );
mCoffee = new ice_latte( 5000, 2 );
ice_latte ice_latte = (ice_latte)mCoffee;
}
}
abstract class Coffee_default{
int price = 0;
int iceLevel = 0;
Coffee_default( int get_Price, int get_iceLevel )
{
this.price = get_Price;
this.iceLevel = get_iceLevel;
}
abstract void exec_drop();
abstract void exec_add_ice();
abstract void exec_taste();
}
class ice_coffee extends Coffee_default
{
int get_Price = 0;
int get_iceLevel = 0;
ice_coffee(int get_Price, int get_iceLevel) {
super(get_Price, get_iceLevel);
// TODO Auto-generated constructor stub
this.get_Price = get_Price;
this.get_iceLevel = get_iceLevel;
System.out.println("---------iceCoffee-----------");
System.out.println("얼음량:" + get_iceLevel + "단계");
System.out.println("가격:" + get_Price + "원");
this.exec_drop();
}
@Override
void exec_drop() {
// TODO Auto-generated method stub
System.out.println(" iceCoffee - 커피내림 ");
this.exec_add_ice();
}
@Override
void exec_add_ice() {
// TODO Auto-generated method stub
System.out.println(" iceCoffee - 얼음첨가 - 얼음첨가단계 : " + this.get_iceLevel);
this.exec_taste();
}
@Override
void exec_taste() {
// TODO Auto-generated method stub
System.out.println(" iceCoffee - 맛이 커피맛이다. ");
}
}
class ice_latte extends Coffee_default
{
int get_Price = 0;
int get_iceLevel = 0;
ice_latte(int get_Price, int get_iceLevel) {
super(get_Price, get_iceLevel);
// TODO Auto-generated constructor stub
this.get_Price = get_Price;
this.get_iceLevel = get_iceLevel;
System.out.println("---------ice_latte-----------");
System.out.println("얼음량:" + get_iceLevel + "단계");
System.out.println("가격:" + get_Price + "원");
this.exec_drop();
}
@Override
void exec_drop() {
// TODO Auto-generated method stub
System.out.println(" ice_latte - 커피내림 ");
this.exec_add_ice();
}
@Override
void exec_add_ice() {
// TODO Auto-generated method stub
System.out.println(" ice_latte - 얼음첨가 - 얼음첨가단계 : " + this.get_iceLevel);
this.mixMilk();
}
public void mixMilk()
{
System.out.println(" ice_latte - 우유첨가 ");
this.exec_taste();
}
@Override
void exec_taste() {
// TODO Auto-generated method stub
System.out.println(" ice_latte - 맛이 커피 + 우유 맛이다. ");
}
}
LIST
'!!...JAVA > !!...JAVA' 카테고리의 다른 글
[java]_예제_컬렉션_01_List (0) | 2022.05.24 |
---|---|
[java]_예제_예외처리_01 (0) | 2022.05.19 |
[java]_예제_For 문 사용법 두가지 (0) | 2022.05.17 |
[java]_예제_추상클래스 & 상속_01 (0) | 2022.05.17 |
[java]_예제_배열_연습문제_03 (0) | 2022.05.04 |