public class Ex01_Coffee {
public static void main(String[] args) {
// new Coffee("콜롬비아"); // 추상 클래스는 new를 할 수 없다.
Coffee[] list = new Coffee[2]; // 객체 생성하는 new가 아님
list[0] = new Espresso("탄자니아", 30);
list[1] = new Latte("케냐", 30, 150);
// watever 는 변수 이름을 뭘로 설정해도 같다.
// whatever 값에 list[0] 부터 들어가는거라 생각하면 된다.
// 보통은 클래스랑 같은 값을 변수로 둔다.
// for 에 클래스 값에 집어넣는 이유는 list 가 그 클래스에서 나온 값이기 때문이다.
for (Coffee whatever : list) {
if (whatever != null) {
whatever.info();
whatever.taste();
}
}
// 아래 list 는 위의 향상 for 문과 같은 값이다.
list[0].info();
list[0].taste();
list[1].info();
list[1].taste();