CS304 Assignment 4 solution idea

No Comments
#include <iostream.h>
#include <string>

using namespace std;
class User
{
private:
int area;
public:
User()
{
area=0;
}
User(int _area):area(_area)
{
}
~User()
{
cout"User class called its destructor"endl;
coutendl;
}
void setArea(int _area)
{
area = _area;
}
int getArea()const
{
return area;
}
};

class Buyer: public User
{
private:
string societyName;
int plotNo;

public:
Buyer()
{
societyName="";
plotNo=0;
}
Buyer(string _societyName, int _plotNo):societyName(_societyName), plotNo(_plotNo)
{
}
~Buyer()
{
cout"Plot class called its destructor"endl;
coutendl;
}
void setSocietyName(string _societyName)
{
societyName = _societyName;
}
string getSocietyName()const
{
return societyName;
}

void setPlotNo(int _plotNo)
{
plotNo = _plotNo;
}
int getPlotNo()const
{
return plotNo;
}
};
class Tenant: public User
{
private:
string societyName;
int flatNo;
public:
Tenant()
{
flatNo=0;
societyName="";
}
Tenant(string _societyName, int _flatNo):societyName(_societyName), flatNo(_flatNo)
{
}
~Tenant()
{
cout"Tenant class called its destructor"endl;
coutendl;
}
void setSocietyName(string _societyName)
{
societyName = _societyName;
}
string getSocietyName()const
{
return societyName;
}

void setFlatNo(int _flatNo)
{
flatNo = _flatNo;
}
int getFlatNo()const
{
return flatNo;
}
};
class Owner: public User
{
private:
string societyName;
int houseNo;
public:
Owner()
{
houseNo=0;
societyName="";
}
Owner(string _societyName, int _houseNo):societyName(_societyName), houseNo(_houseNo)
{
}
~Owner()
{
cout"House class called its destructor"endl;
coutendl;
}
void setSocietyName(string _societyName)
{
societyName = _societyName;
}
string getSocietyName()const
{
return societyName;
}
void setHouseNo(int _houseNo)
{
houseNo = _houseNo;
}
int getHouseNo()const
{
return houseNo;
}
};
int main()
{
Buyer * plot;
Tenant * flat;
Owner * house;
system("pause");
return 0;
}
Next PostNewer Post Previous PostOlder Post Home

0 comments

Post a Comment