// OCP에 위반된다. 소스변경을 해야 한다.
// Template Method 라고 불리는 디자인설계
// 1. 전체 알고리즘을 부모에게 둔다.(public, 절대가상이아니다.)
// 2. 알고리즘이 사용하는 세부구현은 가상함수로 만들어서 자식이 구현한다.(protected로구현)
class IceCream
{
        bool hasPeanut;
        bool hasAlmond;
        bool hasKiwi;
public:
        IceCream( bool b1, bool b2, bool b3 )
               : hasPeanut(b1), hasAlmond(b2), hasKiwi(b3) {}
        int cost()
        {
               int s = IceCost();
               if( hasPeanut ) s += 200;
               if( hasAlmond ) s += 300;
               if( hasKiwi )   s += 500;
               return s;
        }
protected:
        // NVI 가상함수를public으로만들지말자.
        virtual int IceCost() = 0;
};
class Vanila : public IceCream
{
public:
        Vanila( bool b1, bool b2, bool b3 ) : IceCream( b1, b2, b3 ) {}
        virtual int IceCost() { return 1000; }
};
class Strawberry : public IceCream
{
public:
        Strawberry( bool b1, bool b2, bool b3 ) : IceCream( b1, b2, b3 ) {}
        virtual int IceCost() { return 1500; }
};
class Choko : public IceCream
{
public:
        Choko( bool b1, bool b2, bool b3 ) : IceCream( b1, b2, b3 ) {}
        virtual int IceCost() { return 2000; }
};
void main()
{
        Choko c1( 1, 1, 0 );
        cout << c1.cost() << endl;
}