CSI 250L Lab 9 Solution, Spring 2012
American University of Science and Technology · Programming II Lab · 17 pages · Dr. Saeed Raheel · with solution
Showing the first 10 of 17 pages. Download the PDF to see all of it.
More CSI 250L files
- Lab 1 Solution · Spring 2012Lab · with solutionView
- Lab 1 · Spring 2012LabView
- Lab 10 Solution · Spring 2012Lab · with solutionView
- Lab 10 · Spring 2012LabView
- Lab 11 Solution · Spring 2012Lab · with solutionView
- Lab 11 · Spring 2012LabView
- Lab 12 Solution · Spring 2012Lab · with solutionView
- Lab 12 · Spring 2012LabView
Show the text of this lab
Build Log
Build started: Project: Graphics, Configuration: Debug|
Win32
Command Lines
Creating temporary file "c:\Users\SAEED\Documents\Career\Universities Stuff\AUST\Fall 201
[
/O2 /FD /EHsc /MT /Fo"Debug\\" /Fd"Debug\vc80.pdb" /c /TP ".\MAIN.CPP"
".\GraphicalObject.cpp"
]
Creating command line "cl.exe @"c:\Users\SAEED\Documents\Career\Universities Stuff\AUST\F
/errorReport:prompt"
Creating temporary file "c:\Users\SAEED\Documents\Career\Universities Stuff\AUST\Fall 201
[
/OUT:"C:\Users\SAEED\Documents\Career\Universities Stuff\AUST\Fall 2011-2012\CSI250L - Pr
kernel32.lib
".\Debug\GraphicalObject.obj"
".\Debug\MAIN.OBJ"
".\Debug\Square.obj"
]
Creating command line "link.exe @"c:\Users\SAEED\Documents\Career\Universities Stuff\AUST
/ERRORREPORT:PROMPT"
Creating temporary file "c:\Users\SAEED\Documents\Career\Universities Stuff\AUST\Fall 201
[
/outputresource:"..\debug\Graphics.exe;#1" /manifest
".\Debug\Graphics.exe.intermediate.manifest"
]
Creating command line "mt.exe @"c:\Users\SAEED\Documents\Career\Universities Stuff\AUST\F
Creating temporary file "c:\Users\SAEED\Documents\Career\Universities Stuff\AUST\Fall 201
[
@echo Manifest resource last updated at %TIME% on %DATE% > ".\Debug\MT.DEP"
]
Creating command line """c:\Users\SAEED\Documents\Career\Universities Stuff\AUST\Fall 201
Output Window
Compiling...
MAIN.CPP
GraphicalObject.cpp
Generating Code...
Linking...
Embedding
manifest...
Results
Build log was saved at "file://c:\Users\SAEED\Documents\Career\Universities Stuff\AUST\Fa
BuildLog.htm"
Graphics - 0 error(s), 0 warning(s)
#include "GraphicalObject.h"
#include "string.h"
GraphicalObject::GraphicalObject(char *c, char *ds)
{
setColor(c);
setDraw_Style(ds);
}
GraphicalObject::~GraphicalObject()
{
delete color;
delete Draw_style;
}
void GraphicalObject::setColor(char * c)
{
color = new char [strlen(c) + 1];
strcpy(color, c);
}
void GraphicalObject::setDraw_Style(char * ds)
{
Draw_style = new char [strlen(ds) + 1];
strcpy(Draw_style, ds);
}
char *GraphicalObject::getColor()
{
return color;
}
char *GraphicalObject::getDraw_Style()
{
return Draw_style;
}
void GraphicalObject::print()
{
cout << "Color : " << getColor() << ", Draw Style : " << getDraw_Style()
<< endl;
}
#ifndef GRAPHICALOBJECT_H
#define GRAPHICALOBJECT_H
#include <iostream>
using namespace std;
class GraphicalObject
{
public:
GraphicalObject(char *, char *);
~GraphicalObject();
void setColor(char*);
void setDraw_Style(char *);
char *getColor();
char *getDraw_Style();
void print();
protected:
char *color, *Draw_style;
};
#endif
#include "GraphicalObject.h"
#include "Square.h"
#include <iostream>
using namespace std;
int main ()
{
Square *sptr = new Square("Blue", "dotted", 10);
sptr->print();
system("pause");
return 0;
}
#include "Square.h"
#include "string.h"
#include <iostream>
using namespace std;
Square::Square(char *c, char *dr, int s):GraphicalObject(c, dr)
{
side = s;
}
Square::~Square() { }
void Square::print() const
{
cout << "The color is " << color << endl;
cout << "The drawstyle is " << Draw_style << endl;
cout << "The side is " << side << endl;
cout << "The area is " << getarea() << endl;
}
#include "GraphicalObject.h"
#ifndef SQUARE_H
#define SQUARE_H
class Square:public GraphicalObject
{
public:
Square(char *, char *, int);
~Square();
int getarea() const { return (side * side); }
void print() const;
private:
int side;
static int cout;
};
#endif
#include"address.h"
address::address(char *c, char *a)
{
setcity(c);
setarea(a);
}
address::address()
{
setcity(" ");
setarea(" ");
}
void address::setarea(char *a)
{
area=new char[strlen(a)+1];
strncpy(area,a,strlen(a));
area[strlen(a)]='\0';
}
void address::setcity(char *c)
{
int l1=strlen(c);
city=new char[l1+1];
strncpy(city,c,l1);
city[l1]='\0';
}
char* address::getcity()
{
return city;
}
char* address::getarea()
{
return area;
}
void address::print()
{
cout<<"the city is "<<getcity()<<endl;
cout<<"the area is "<<getarea()<<endl;
}
address::~address()
{
delete[]city;
city=0;
delete[]area;
area=0;
}
#include<iostream>
#include<cstring>
#ifndef ADD_H
#define ADD_H
using namespace std;
class address{
private:
char*city;
char*area;
public:
address();
address(char[],char[]);
void print();
void setcity(char*);
void setarea(char*);
char* getcity();
char* getarea();
~address();
};
#endif
#include"address.h"
#include"employee.h"
#include"teacher.h"
int main()
{
int n;
int idd;
int r;int h;
char c[20];
char a[20];
char f[30];
char l[30];
cout<<"how many teachers you want to enter "<<endl;
cin>>n;
teach *t=new teach[n];
for(int i=0;i<n;i++)
{
cout<<"please enter the city,area,id,fname,lname,rank,hours worked
for teacher #"<<i+1<<endl;
cin>>c>>a>>idd>>f>>l>>r>>h;
t[i].setadres(c,a);
t[i].setfname(f);
t[i].sethour(h);
t[i].setid(idd);
t[i].setlname(l);
t[i].setrank(r);
t[i].settotalsal();
}
int id = 0 , max = 0;
for(int y=0;y<n;y++)
if (t[y].calcsalary()>max)
{
id = t[y].getid();
max = t[y].calcsalary();
}
for(int y=0;y<n;y++)
if (t[y].getid()==id)
{
cout<<"The maximum salary is for teacher #"<< id << " and is
worth " <<t[y].calcsalary()<<endl;
break;
}
cout << "The total salary for all teachers is
"<<teach::gettsalary()<<endl;
system("pause");
return 0;
}
#include"employee.h"
emp::emp(int i, char*f, char*l, int r,char*c,char*a):adres(c,a)
{
setid(i);
setfname(f);
setlname(l);
setrank(r);
}
void emp::setid(int i)
{
id=i;
}
void emp::setfname(char *f)
{
int l2=strlen(f);
fname=new char[l2+1];
strncpy(fname,f,l2);
fname[l2]='\0';
}
void emp::setlname(char *l)
{
int l3=strlen(l);
lname=new char[l3+1];
strncpy(lname,l,l3);
lname[l3]='\0';
}
void emp::setrank(int r)
{
if(r>=1&&r<=3)
rank=r;
else
rank=0;
}
void emp::setadres(char*c,char*a)
{
adres.setcity(c);
adres.setarea(a);
}
int emp::getid()
{
return id;
}
char* emp::getfname()
{
return fname;
}
char* emp::getlname()
{
return lname;
}
int emp::getrank()
{
return rank;
}
address emp::getadres()
{
return adres;
}
void emp::print()
{
cout<<"the id is "<<id<<endl;
cout<<"the first name is "<<fname<<endl;
cout<<"the last name is "<<lname<<endl;
cout<<"the rank is "<<rank<<endl;
adres.print();
}
emp::~emp()
{
delete[]fname;
fname=0;
delete[]lname;
lname=0;
}
#include"address.h"
#ifndef EMP_H
#define EMP_H
class emp{
private:
int id;
char*fname;
char*lname;
address adres;
int rank;
public:
emp(int=0,char[]="",char[]="",int=0,char[]="",char[]="");
void setid(int);
void setfname(char*);
void setlname(char*);
void setadres(char*,char*);
void setrank(int);
int getid();
char*getfname();
char*getlname();
address getadres();
int getrank();
void print();
~emp();
};
#endif
#include"teacher.h"
teach::teach(int h, int i, char *f, char *l, int r, char *c, char
*a):emp(i,f,l,r,c,a)
{
sethour(h);
settotalsal();
}
void teach::sethour(int h)
{
hour=h;
}
int teach::gethour()
{
return hour;
}
void teach::settotalsal()
{
tsalary+=calcsalary();
}
int teach::calcsalary()
{
int s;
if(getrank()==1)
{s=hour*75000;
return s;
tsalary+=s;}
else
if(getrank()==2)
{s=hour*50000;
return s ;
tsalary+=s;}
else
if(getrank()==3)
{s=hour*40000;
return s ;
tsalary+=s;}
}
int teach::gettsalary()
{
return tsalary;
}
void teach::print()
{
cout<<"the hours are "<<hour<<endl;
emp::print();
}
int teach::tsalary=0;
#include"employee.h"
#ifndef TEACH_H
#define TEACH_H
class teach:public emp{
private:
int hour;
static int tsalary;
public:
teach(int=0,int=0,char[]="",char[]="",int=0,char[]="",char[]="");
void sethour(int);
int gethour();
int calcsalary();
static int gettsalary();
void print();
void settotalsal();
};
#endif