추상클래스 자체만으로는 인스턴스를 생성하지 못한다는 제약이 있음
이걸 이용해서 상속 객체를 생성하는 팩토리 패턴에서 주로 사용..
public abstract class Customer{
protected string name;
protected List<Product> orders = new List<Product>();
public abstract int GetTotalPaid();
}
public class MVP : Customer{
public override int GetTotalPaid(){
… …
}
}
public interface CustomerFactory{
Customer CreateCustomerBy(CustomerType type);
}
댓글 0