Facade_Pattern - 8BitsCoding/RobotMentor GitHub Wiki

์ •์˜

ํ†ต์ผ๋œ ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ํ†ตํ•ด ๋ณต์žกํ•œ ์„œ๋ธŒ์‹œ์Šคํ…œ๋“ค์„ ๊ฐ„๋‹จํžˆ ์‚ฌ์šฉํ•˜๋„๋ก ๋งŒ๋“  ํŒจํ„ด

๋งค์šฐ ๊ฐ„๋‹จ


์˜ˆ์‹œ๋กœ ์„ค๋ช…

class BIOS
{
public:
    void operation() { cout << "\t-BIOS Loading..." << endl; }
};
 
class CPU
{
public:
    void operation() { cout << "\t-CPU Processing..." << endl; }
};
 
class MEMORY
{
public:
    void operation() { cout << "\t-Memory Loading..." << endl; }
};
 
class HDD
{
public:
    void operation() { cout << "\t-Hard Disk Loading..." << endl; }
};
 
class Computer
{
public:
    Computer(BIOS *a, CPU *b, MEMORY* c, HDD* d) : mBios(a), mCpu(b), mMemory(c), mHdd(d) {}
 
public:
    void Booting() 
    {
        cout << "+Computer Booting Start" << endl;
        
        mBios->operation();
        mCpu->operation();
        mMemory->operation();
        mHdd->operation();
 
        cout << "+Computer Booting Complete" << endl;
    }
 
private:
    BIOS* mBios;
    CPU* mCpu;
    MEMORY* mMemory;
    HDD* mHdd;
};
 
//------------------------------------------------------------------
// Main
int _tmain(int argc, _TCHAR* argv[])
{
    BIOS bios;
    CPU cpu;
    MEMORY memory;
    HDD hdd;
 
    Computer mComputer(&bios, &cpu, &memory, &hdd);
    mComputer.Booting();
 
    getchar();
 
    return 0;
}

์ฐธ๊ณ ์‚ฌ์ดํŠธ