-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoffeShop.java
More file actions
36 lines (32 loc) · 1.22 KB
/
CoffeShop.java
File metadata and controls
36 lines (32 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package chap07;
public class CoffeShop {
public static void main(String[] args) {
System.out.println("****java nara CoffeeShop영업개시****");
Beverage[] beverage = new Beverage[5];
beverage[0] = new Coffee("Cappuccino");
beverage[1] = new Coffee("CafeLatte");
beverage[2] = new Tea("ginsengTea");
beverage[3] = new Coffee("CafeLatte");
beverage[4] = new Tea("redginsengTea");
getSalesInfo(beverage);
System.out.println("총 판매 금액==>" + getTotalPrice(beverage));
System.out.println("Coffe의 판매 개수=>" + Coffee.amount + "잔");
System.out.println("Tea의 판매 개수=>" + Tea.amount + "잔");
}
// 결과와 같이 가격을 구하고 판매정보를 출력할 수 있도록 getSalesInfo메소드를 작성하세요
public static void getSalesInfo(Beverage[] beverage) {
for (int i = 0; i < beverage.length; i++) {
System.out.print((i+1) + " 번째 ");
beverage[i].print();
System.out.println();
}
}
// 결과와 같이 총 판매금액을 구할 수 있도록 getTotalPrice메소드를 작성하세요.
public static int getTotalPrice(Beverage[] beverage) {
int result = 0;
for ( int i = 0; i < beverage.length; i++) {
result += beverage[i].getPrice();
}
return result;
}
}