Java/Excercise

generic ch02 MainTest

낭구리 2021. 9. 3. 15:18
package ch02;

public class MainTest1 {

	public static void main(String[] args) {

		Powder powder = new Powder();
		Plastic plastic = new Plastic();
		
		ThreeDPrinter1 dPrinter1 = new ThreeDPrinter1();
		//재료 셋팅
		dPrinter1.setMaterial(powder);
		
		//재료를 꺼내서 확인
		Powder tempPowder = dPrinter1.getMaterial();
		System.out.println(tempPowder.toString());
		System.out.println("======");
		
		////
		ThreeDPrinter2 dPrinter2 = new ThreeDPrinter2();
		dPrinter2.setMaterial(plastic);
		Plastic plastic2 = dPrinter2.getMaterial();
		System.out.println(plastic2.toString());
		System.out.println("----");
		
		ThreeDPrinter3 printer3 = new ThreeDPrinter3();
		//재료셋팅
		printer3.setMaterial(powder);

		//재료를 꺼내보기
		Powder tempPowder2= (Powder)printer3.getMaterial();
		System.out.println(tempPowder2.toString());
		
		
		
		
		
	}

}

'Java > Excercise' 카테고리의 다른 글

generic ch03 GenericPrinterTest  (0) 2021.09.03
generic ch03 genericPrinter<T>  (0) 2021.09.03
generic ch02 ThreeDPrinter  (0) 2021.09.03
generic ch01 제네릭의 정의  (0) 2021.09.03
object ch02 StringBuilderTest  (0) 2021.09.02