PDA

View Full Version : plz help error remove urgent



jazikhan001
11-16-2008, 07:59 PM
#include<iostream.h>
#include<string.h>
enum Status{outoforder,ok};

//enum bool{false,true};
template <class T>
class List{
public :
List () { }
List (int s){
maxSize=s;
used=0;
a= new T [maxSize];
}
//~List () { delete []a;}
bool addObjects(T p){
if (!isFull()){
a[used]=p;
used ++;
return true;
}
else
return false;
}
int getMaxSize() { return maxSize;}

int getUsed() { return used;}
bool setObject (int index,T p )
{ if ((index <used )&&(index>=0)){
a[index]=p;
return true;
}
else
return false;
}

bool getObject (int index,T &p )
{ if (!isEmpty()) {
if ((index <used )&&(index>=0)){
p=a[index];
return true;
}
else
return false;
}
else
return false;
}

int isFull() { return used==maxSize;}
int isEmpty () { return used==0;}

private :
T *a;
int maxSize;
int used;
};
class HardDisk{
public:
HardDisk(){}
HardDisk(int c){cap=c;}
void setHd(int c){cap=c;}
int getHd(){return cap;}
private:
int cap;
};
class Processor{
public:
Processor(){}
Processor(float c){Cs=c;}
void SetPro(float c){Cs=c;}
float getPro(){return Cs;}
private:
float Cs;
};

class Ram{
public:
Ram(){}
Ram(int c){Cap=c;}
void setRam(int c){Cap=c;}
int getRam(){return Cap;}
private:
int Cap;
};

class Monitor{
public:
Monitor(){}
Monitor(char *t){strcpy(Type,t);}
void setM(char *t){strcpy(Type,t);}
char* getM(){return Type;}
private:
char Type[15];
};
class Keyboard{
public:
Keyboard(){}
Keyboard(char *t){strcpy(Type,t);}
void setK(char *t){strcpy(Type,t);}
char* getK(){return Type;}
private:
char Type[15];


};
class Mouse{
public:
Mouse(){}
Mouse(char *t){strcpy(Type,t);}
void setMo(char *t){strcpy(Type,t);}
char* getMo(){return Type;}
private:
char Type[15];

};
class CdRom{
public:
CdRom(){}
CdRom(char *t){strcpy(Type,t);}
void setCd(char *t){strcpy(Type,t);}
char* getCd(){return Type;}

private:
char Type[15];
};
class Speaker{
public:
Speaker(){}

Speaker(char* s){Size=s;}
void setSpeaker(char* s){Size=s;}
char* getSpeaker(){return Size;}
private:
char* Size;

};
class Computer{

public:
Computer(){}
Computer(Status s, int h,float pr,int rm,char* m,char *kb,char *mon):hd(h),p(pr),r(rm),m(mon),mo(m),k(kb){
status=s;}// cd=NULL;s=NULL;}

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

void setHardDisk(int h){hd.setHd(h);}
int getHardDisk(){return hd.getHd();}

void setProcessor(float pr){p.SetPro(pr);}
float getProcessor(){return p.getPro();}

void setRam(int ra){r.setRam(ra);}
int getRam(){r.getRam();}

void setMonitor(char *mo){m.setM(mo);}
char *getMonitor(){return m.getM();}

void setKeyboard(char *ke){k.setK(ke);}
char *getKeyboard(){return k.getK();}

void setMouse(char *m){mo.setMo(m);}
char *getMouse(){return mo.getMo();}

void setCd(char *c){
if(cd!=NULL)
cd->setCd(c);
}
char * getCd(){
if(cd!=NULL)
return cd->getCd();
else
return NULL;
}
void setSpeaker(char *c){
if(s!=NULL)
s->setSpeaker(c);
}
char * getSpeaker(){
if(s!=NULL)
return s->getSpeaker();
else
return NULL;
}
int addSpeaker(char *t){
if(s==NULL){
s=new Speaker(t);
return 1;
}
else
return 0;
}
int removeSpeaker(){
if(s!=NULL){
delete s;
return 1;
}
else
return 0;
}


int addCd(char *t){
if(cd==NULL){
cd=new CdRom(t);
return 1;
}
else
return 0;
}
int removeCd(){
if(cd!=NULL){
delete cd;
return 1;
}
else
return 0;
}
/* void print(){
cout<<"\n.....................................\n";
cout<<"Status = "<<status<<endl;
cout<<"Hard Disk = "<<getHardDisk()<<endl;
cout<<"Processor = "<<getProcessor()<<endl;
cout<<"Ram = "<<getRam()<<endl;
cout<<"KeyBoard = "<<getKeyboard()<<endl;
cout<<"Monitor = "<<getMonitor()<<endl;
cout<<"Mouse = "<<getMouse()<<endl;
if(cd!=NULL){
{ cout<<"CDROM = "<<getCd()<<endl;}
else
cout<<"No CD Rom "<<endl;


if(s!=NULL){
cout<<"Speaker = "<<getSpeaker()<<endl;
else
cout<<"No Speaker "<<endl;
}
} */

private:
Status status;
HardDisk hd;
Processor p;
Ram r;
Monitor m;
Keyboard k;
Mouse mo;
CdRom *cd;
Speaker *s;
};

class Lab{
public:
Lab(int no , int size):ls(size){
labno=no;
}
int addComputer(Computer p){return ls.addObjects(p);}
void printComputer(){
Computer t;
for(int i=0;i<ls.getUsed();i++){
ls.getObject(i,t);
//t,print();
}
}
private:
int labno;
List <Computer> ls;
};
void main(){
Lab l1(1,10),l2(2,10),l3(3,10);
Computer ob (ok,80,2000,1,"Ball","Standard","14 in Flat ");
//ob.print();
l1.addComputer(ob);
}

Millenia
11-16-2008, 09:05 PM
Well I have absolutely no idea what you are trying to say. Please can you explain what is wrong, what you want, or what you need. All I can see is some code that isn't explained.

Also, please use [code] tags. It makes it easier for people to read and understand your code, as well as making the forums look neater.

Note: I added the [code] tags for you this time, to make it easier for other people to help you. But I won't in the future.

jazikhan001
11-16-2008, 09:09 PM
actually while running the program iam facing these errors i did'nt created this program my frnd created it so i don't know mch.
errors iam faceing are:-
1. functions containing for are not expanded inline.
2. functions containing missing return statements are not expanded.
3. tye name expected.
4. declaration missing ;
5. undefinid symbol 'a'
6. 'addobjects' is not a member of 'list '.

tomws
11-17-2008, 01:59 AM
You should probably hope your prof doesn't care enough about his/her assignments to use Google. Otherwise, you're quite busted for 1) plagiarism, and 2) having no idea how "your own" program works.