Java/Excercise

generic ch02 ThreeDPrinter

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

public class Plastic {

	@Override
	public String toString() {
		return "재료는 plastic입니다";
	}


}

 

package ch02;

public class Powder {

	@Override
	public String toString() {
		return "재료는 powder입니다.";
	}
}

 

package ch02;

public class ThreeDPrinter1 {

	private Powder material;
	//powder 참조타입
	
	public Powder getMaterial() {
		return material;
	}
	
	public void setMaterial(Powder material) {
		this.material = material;
	}
	
}

 

package ch02;

public class ThreeDPrinter2 {

	private Plastic material;
	
	public Plastic getMaterial() {
		return material;
	}
	
	public void setMaterial(Plastic material) {
		this.material = material;
	}
}

 

 

package ch02;

public class ThreeDPrinter3 {

	private Object material;

	public Object getMaterial() {
		return material;
	}

	public void setMaterial(Object material) {
		this.material = material;
	}
	
}

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

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