You are on page 1of 22

Lab Project

Name & Sap id


Saraad Bashir 70110009
Shahroz 70110343
Fazal Rafi
Ateeb Zahid
Section: BSCS- 3F

The University of Lahore


UML diagram of code:
User Manual:
At first, when program is started you have to write name of society and then the city in which
it is located.
After that it will ask you the number of blocks in the society. Then, number of sectors in each
block afterword it will ask for number of streets in each sector then number of houses in each
street.
Then it will ask you how many you want to Allocate house to owner. Enter the block, sector
according to block ,then enter street number according to the sector and then house number
according to the street. After this enter owner name.
It will ask again weather you want to add more owner or not press ‘t’ or ‘T’ to terminate this
section or any other key to add more owners.
After terminating this section the program will display the sketch of society.
And then the program will ask to terminate on specific key ‘t’ or ‘T’ . after pressing it the
program will terminate.
Pictures of code:
Pictures of output:
Code:
#include<iostream>
#include<string>
using namespace std;
class Houses
{

static int house;


bool owned;
string owner;
int num ,size;
public:

Houses()
{
house++;
num = house;
owned = 0;

cout << "\t\t\t\t House No. " << num << endl;
}

void display_house()
{

cout << "\t\t\t\t House No. " << num;


if (owned==1)
cout << ", Owned By: " << owner << endl;
else
cout << endl;
}
void AddOwner(string owner_name)
{
cout << "Owner's Name: ";
owner=owner_name;
cin>>owner;
owned = 1;
}
};

class Streets
{
protected:
static int street;
Houses* H;
int num,size;
public:

Streets()
{
street++;
num = street;
cout << "\t\t\t Street No. " << num << endl;
cout << "Enter number of Houses :: ";
cin >> size;
this->H = new Houses[this->size];

}
void display_street()
{

cout << "\t\t\t Street No. " << num << endl;

for (int i = 0; i < this->size; i++)


{
H[i].display_house();
}
}
void AddOwner(int house , string owner_name)
{
cout << "Enter House: ";
// int i;
cin>>house;
H[house-1].AddOwner(owner_name);
}
};

class Sectors
{
protected:
static char sector;
char num;
int size;
Streets* Str;
public:

Sectors()
{
sector++;
num = sector;
cout << "\t\t Sector " << num << endl;
cout << "Enter number of Streets :: ";
cin >> size;
this->Str = new Streets[this->size];

void display_sector()
{
cout << "\t\tSector " << num << endl;

for (int i = 0; i < size; i++)


{
Str[i].display_street();
}
}
void AddOwner(int street , int house , string owner_name )
{
cout << "Enter Street: ";
// int street;
cin >> street;
Str[street-1].AddOwner(house , owner_name);
}
};

class Blocks
{
protected:
static char block;
char num;
int size;
Sectors* S;
public:

Blocks()
{
block++;
num = block;
cout << "\t\t Block " << num << endl;
cout << "Enter number of sectors :: ";
cin >> size;
this->S = new Sectors[this->size];
}

void display_blocks()
{
cout << "Block " << num << endl;
for (int i = 0; i < size; i++)
{
S[i].display_sector();
}
}
void AddOwner(char sector , int street ,int house ,string owner_name)
{
cout << "Enter Sector number: ";
// char sector;
cin >> sector;
int s = sector - 'A';
S[s].AddOwner(street , house , owner_name);
}
};

int Houses::house = 0;
int Streets::street = 0;
char Sectors::sector = 64;
char Blocks::block = 64;

class Society
{
private:
string soci, city;
int size;
Blocks* B;
public:
Society()
{
cout << "Enter Name of Society ";
getline(cin, soci);
cout << "Enter name of City ";
getline(cin, city);
cout << "Enter number of blocks ";
cin >> size;
this->B = new Blocks[this->size];

void display()
{
cout << "\n\n*******************************************"<<endl;
cout << soci << "\t" << city << endl;
for (int i = 0; i < size; i++)
{
B[i].display_blocks();

}
}
void set(char block , char sector , int street, int house, string owner_name)
{
cout << "************************************************"<<endl;
cout <<"Enter Address to allocate house to owner" << endl;
cout << "Block name: ";
//char block;
cin >> block;
int b = block - 'A';
B[b].AddOwner(sector, street , house , owner_name);
}
};

int main()
{
char block , sector , ter, ter1;
int street, house ,size ;
string owner_name;

do{

Society society;

do{
cout <<"\nEnter number of owners do you want to Allocate houses";
cin >> size;
for (int i=0 ;i < size; i++ )
{
society.set( block , sector , street , house ,owner_name );
}
cout <<"If you have finish setting the Owners"<<endl;
cout <<"Then press 't' or 'T' "<< endl;
cout <<"Or if you want to enter more press any other key" << endl;
cin >> ter;
}while( ter!='t' && ter!='T' );
society.display();
cout <<"If you want to terminate Program then press T or t" << endl;
cin >> ter1;
}while ( ter1!='t' && ter1!='T' );

You might also like