1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
"furniture management system.h"
#include "Furniture.h"
#include "Sofa.h"
#include "Bookcase.h"
class Furmansys
{
private:
Furniture **furnArray;
int size;
int numFurn;
public:
Furmansys();
Furmansys(const Furmansys &obj);
void addFurniture();
~Furmansys();
}
and here is
"furniture management system.cpp"
#include "Furniture Management System.h"
Furmansys::Furmansys()
{
size=1;
numFurn=0;
furnArray=new Furniture*[size];
for (int i=0; i<size; i++)
{
furnArray[i]=NULL;
}
}
Furmansys::Furmansys(const Furmansys &obj)
{
size=obj.size;
furnArray=new Furniture*[size];
for (int i=0; i<size; i++)
{
furnArray[i]=obj.furnArray[i];
}
}
void Furmansys::addFurniture()
{
string furntype;
string name;
string price;
string stock;
string seats;
string color;
string wood;
string height;
if (numFurn >= size)
{
size+=1;
Furniture **temp= new Furniture*[size];
for (int i=0; i<size; i++)
{
temp[i]=NULL;
}
for (int i=0; i<numFurn; i++)
{
temp[i]=furnArray[i];
}
delete [] furnArray;
furnArray=temp;
temp=NULL;
}
cin.ignore();
cout<<"Please wite the type of the furniture you wish to add (Sofa or Bookcase): ";
getline(cin,furntype);
if (furntype=="Sofa" || furntype=="sofa")
{
cout<<"Please write your Sofa's name: ";
getline(cin,name);
cout<<"Please write your Sofa's price: ";
getline(cin,price);
cout<<"Please write your Sofa's stock availability: ";
getline(cin,stock);
cout<<"Please write your Sofa's seat number: ";
getline(cin,seats);
cout<<"Please write your Sofa's color: ";
getline(cin,color);
furnArray[numFurn++]=new Sofa(name, price, stock, seats, color);
}
else if (furntype=="Bookcase" || furntype=="bookcase")
{
cout<<"Please write your Bookcase's name: ";
getline(cin,name);
cout<<"Please write your Bookcase's price: ";
getline(cin,price);
cout<<"Please write your Bookcase's stock availability: ";
getline(cin,stock);
cout<<"Please write your Bookcase's wood type: ";
getline(cin,wood);
cout<<"Please write your Bookcase's height: ";
getline(cin,height);
furnArray[numFurn++]=new Bookcase(name, price, stock, seats, color);
}
}
Furmansys::~Furmansys()
{
for (int i=0; i<numFurn; i++)
{
delete furnArray[i];
}
delete [] furnArray;
furnArray=NULL;
}
|