#include<iostream>
#include<cstdlib>
#include<ctime>
#include<string>
#include<GL/glew.h>
#include <GL/glut.h>
#include<GLFW/glfw3.h>
#define MAX 1000
using namespace std;
#define numVAOs 1
class CPU
{
public:
virtual void calculator() = 0;
};
class VideoCard
{
public:
virtual void display() = 0;
};
class Memory
{
public:
virtual void storage() = 0;
};
class Computer
{
public:
Computer(CPU* cp_u, VideoCard* vc, Memory* me)
{
c_pu = cp_u;
v_c = vc;
m_e = me;
}
void work()
{
c_pu->calculator();
v_c->display();
m_e->storage();
}
~Computer()
{
if (c_pu != NULL)
{
delete c_pu;
c_pu = NULL;
}
else if (v_c != NULL)
{
delete v_c;
v_c = NULL;
}
else if (m_e != NULL)
{
delete m_e;
m_e = NULL;
}
}
private:
CPU* c_pu;
VideoCard* v_c;
Memory* m_e;
};
class InterCPU :public CPU
{
public:
virtual void calculator()
{
cout << "Inter的CPU在计算" << endl;
}
};
class InterVideocard :public VideoCard
{
public:
virtual void display()
{
cout << "Inter的显卡在显示" << endl;
}
};
class InterMemory :public Memory
{
public:
virtual void storage()
{
cout << "Inter的内存条在存储" << endl;
}
};
class AMDCPU :public CPU
{
public:
virtual void calculator()
{
cout << "AMD的CPU在计算" << endl;
}
};
class AMDVideocard :public VideoCard
{
public:
virtual void display()
{
cout << "AMD的显卡在显示" << endl;
}
};
class AMDMemory :public Memory
{
public:
virtual void storage()
{
cout << "AMD的内存条在存储" << endl;
}
};
void test01()
{
CPU* interCpu = new InterCPU;
VideoCard* interCard = new InterVideocard;
Memory* interMem = new InterMemory;
CPU* amdCpu = new AMDCPU;
VideoCard* amdCard = new AMDVideocard;
Memory* amdMem = new AMDMemory;
Computer* computer1 = new Computer(interCpu, interCard, interMem);
computer1->work();
delete computer1;
cout << "-------------------" << endl;
cout << "第二台电脑开始工作" << endl;
Computer* computer2 = new Computer(amdCpu, amdCard, amdMem);
computer2->work();
delete computer2;
cout << "-------------------" << endl;
cout << "第三台电脑开始工作" << endl;
Computer* computer3 = new Computer(amdCpu, interCard, interMem);
computer3->work();
delete computer3;
}
int main()
{
test01();
}