728x90 method return1 [JAVA] ch07-17. 객체 지향 17 public class Ex17 { public static void main(String[] args){ Buyer buyer = new Buyer(); Tablet tablet = new Tablet(); PC pc = new PC(); buyer.buy(tablet); buyer.buy(pc); } } class Product{ int price; int bonus; Product(int price){ this.price = price; bonus = price/10; } } class Tablet extends Product{ Tablet(){ super(100); } public String toString(){ return "Tablet"; } } class PC extends Product{.. JAVA/예제 2017. 8. 22. 이전 1 다음 728x90