자바의 정석 문제풀이 14

Book_368_7_21

다형성 class Product{ int price; int bonusPoint; public Product(int price) { this.price=price; bonusPoint=(int)(price/10.0); //보너스점수는 제품가격의 10% } } class Tv extends Product{ Tv(){ //부모클래스의 생성자 product(int price)를 호출 super(100); //tv의 가격 } //object클래스의 tostring()을 오버라이딩 public String toString() {return "Tv";} } class Computer extends Product{ Computer(){super(200);} public String toString() {return ..