// Product
package ch03_quiz;
/*
* Product class 를 정의하세요
* - 제품이름, 가격의 관리가 가능합니다
*/
public class Product {
private String name;
private int price;
public Product(String name, int price) {
this.name = name;
this.price = price;
}
public String getname() {return name;}
public void setname(String name) { this.name=name; }
public int getprice() {return price;}
public void setprice(int price) { this.price=price; }
public String toString() {
return "제품이름 : " + name + " 가격 : " + price + "원";
}
}
--------------------------------------------------------------------------------
//Foo
package ch03_quiz;
/*
* Foo class 를 정의하세요
* - 제너릭 타입 하나를 가지는 class 입니다
*/
public class Foo<F> {
private F foo;
public Foo(){}
public Foo(F foo) { this.foo = foo; }
public F getfoo() {return foo;}
public void setfoo(F foo) { this.foo = foo; }
}
package ch03_quiz;
public class QuizTest {
/*
* Foo class에 Product class 적용한 객체를 생성하세요.
*/
public static void main(String[] args) {
Foo<Product> fo = new Foo<>(new Product("우유",1000));
System.out.println(fo.getfoo());
}
}