#include <iostream>
using namespace std;
enum JB {P1=1,P2,P3,P4,P5,P6,P7};
class CPU
{
private:
JB rank ;
int PL;
float FY;
public:
CPU (JB r, int f, float v)
{
JB rank = r;
PL = f;
FY = v;
cout<<"构造了一个CPU!"<<endl;
}
~CPU () { cout<<"析构了一个CPU!"<<endl; }
JB GetRank() const { return rank; }
int GetPL() const { return PL; }
float GetFY() const { return FY; }
void SetRank(JB r) { rank = r; }
void SetPL(int f) { PL = f; }
void SetFY(float v) { FY = v; }
void Run() {cout<<"CPU开始运行!"<<endl; }
void Stop() {cout<<"CPU停止运行!"<<endl; }
};
class RAM
{
private:
int size;
public:
RAM (int s)
{
size = s;
cout<<"构造了一个RAM!"<<endl;
}
~RAM () {cout<<"析构了一个RAM!"<<endl; }
int Getsize() const { return size; }
void Setsize(int s) { size = s; }
void Run() {cout<<"RAM开始运行!"<<endl; }
void Stop() {cout<<"RAM停止运行!"<<endl; }
};
class COMPUTER
{
private:
CPU cpu;
RAM ram;
public:
COMPUTER()
{
cout<<"构造了一个COMPUTER!"<<endl;
}
~COMPUTER ()
{
cout<<"析构了一个COMPUTER!"<<endl;
}
void Run()
{
cout<<"COMPUTER开始运行!"<<endl;
cpu.Run();
ram.Run();
}
void Stop()
{
ram.Stop();
cpu.Stop();
cout<<"COMPUTER停止运行!"<<endl;
}
};
void main()
{
COMPUTER a;
a.Run();
a.Stop();
}