[JAVA] ch07-17. 객체 지향 17
·
JAVA/예제
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{..