Вы находитесь на странице: 1из 8

Aggregation 1

============================================
#include <stdlib.h>
#include <string.h>
#include <iostream.h>

class Hdd{
public:
Hdd(){}
Hdd(int hCap)
{
hddCapacity=hCap;
}

void setHddCapacity(int hCap)


{
hddCapacity=hCap;
}

int getHddCapacity()
{
return hddCapacity;
}

private:
int hddCapacity;
};

class Ram{
public:
Ram(){}
Ram(int rCap)
{
ramCapacity=rCap;
}

void setRamCapacity(int rCap)


{
ramCapacity=rCap;
}

int getRamCapacity()
{
return ramCapacity;
}

private:
int ramCapacity;
};

class Processor{
public:
Processor(){}
Processor(int s)
{
clockSpeed=s;
}

void setProcessorSpeed(int s)
{
clockSpeed=s;
}

int getProcessorSpeed()
{
return clockSpeed;
}

private:
int clockSpeed;
};

class Mouse{

public:

Mouse(){}
Mouse(char *mTyp)
{
strcpy(mouseType,mTyp);
}
void setMouseType(char *mTyp)
{
strcpy(mouseType,mTyp);
}

char *getMouseType()
{
return mouseType;
}

private:
char mouseType[20];

};

class KeyBoard{

public:

KeyBoard(){}
KeyBoard(char *kTyp)
{
strcpy(keyboardType,kTyp);
}
void setKeyboardType(char *kTyp)
{
strcpy(keyboardType,kTyp);
}

char *getKeyboardType()
{
return keyboardType;
}

private:
char keyboardType[20];

};

class Monitor{

public:

Monitor(){}
Monitor(char *mTyp)
{
strcpy(monitorType,mTyp);
}

void setMonitorType(char *mTyp)


{
strcpy(monitorType,mTyp);
}

char *getMonitorType()
{
return monitorType;
}

private:
char monitorType[20];

};

class Speaker{
public:
Speaker(){}
Speaker(int sSize)
{
speakerSize=sSize;
}

void setSpeakerSize(int sSize)


{
speakerSize=sSize;
}

int getSpeakerSize()
{
return speakerSize;
}

private:
int speakerSize;
};

class CdRom{

public:
CdRom(){}

CdRom(char *cTyp)
{
strcpy(cdRomType,cTyp);
}

void setCdRomType(char *cTyp)


{
strcpy(cdRomType,cTyp);
}

char *getCdRomType()
{
return cdRomType;
}

private:
char cdRomType[20];

};

enum Status {OutOfOrder,OK};


class Computer{
public:
Computer(){}
Computer(int hCap,int rCap,int pSped, char *mTyp, char *kTyp,
char
*moTyp):hd(hCap),r(rCap),p(pSped),m(mTyp),k(mTyp),mo(moTyp)
{
sp=NULL;
cd=NULL;
}

void addSpeaker(int s)
{
sp=new Speaker(s);
}

void deleteSpeaker()
{
delete sp;
}
void addCdRom(char *ct)
{
cd=new CdRom(ct);
}

void deleteCdRom()
{
delete cd;
}

void setSpeaker(int s)
{
if(sp!=NULL)
sp->setSpeakerSize(s);

int getSpeaker()
{
if(sp!=NULL)
return sp->getSpeakerSize();
else
return -1;

void setCdRom(char *cs)


{
if(cd!=NULL)
cd->setCdRomType(cs);
}

char *getCdRom()
{
if(cd!=NULL)
return cd->getCdRomType();
else
return "?";
}

void setStatus(Status s)
{
status=s;
}

Status getStatus()
{
return status;
}

void setHdd(int sHdd)


{
hd.setHddCapacity(sHdd);
}

int getHdd()
{
hd.getHddCapacity();
}

void setRam(int rm)


{
r.setRamCapacity(rm);
}

int getRam()
{
r.getRamCapacity();
}

void setProcessor(int sp)


{
p.setProcessorSpeed(sp);
}

int getProcessor()
{
p.getProcessorSpeed();
}

void setMouse(char *mt)


{
m.setMouseType(mt);
}
char *getMouse()
{
m.getMouseType();
}

void setKeyBoard(char *kt)


{
k.setKeyboardType(kt);
}

char *setKeyBoard()
{
k.getKeyboardType();
}

void setMonitor(char *mot)


{
mo.setMonitorType(mot);
}

char *setMonitor()
{
mo.getMonitorType();
}

private:

Status status;
Hdd hd;
Ram r;
Processor p;
Mouse m;
KeyBoard k;
Monitor mo;
Speaker *sp;
CdRom *cd;

};

http://www.ravianeducation.blogspot.com
FARHAN: 03008855006

Вам также может понравиться