How Can we Put this in the Following Program? In the main function, after creating the Society object and before society.display(), set the owner names of a few houses, and make sure that society.display() displays this information. The main function will look like this: Pic 1 to Pic 2.... Program: //header file #include //using namespace using namespace std; char block_number = 'A'; char sector_number = 'A'; int street_number = 1; int house_number = 1; class house{ public: int name; house * next; house(int n){ name = n; next = NULL; } void display(){ cout<<"\t\t\t\tHouse "<next = t2; temp = temp->next; } return ret; } class street{ public: int name; street * next; int no_of_houses; house * head; street(int n){ int n_h; name = n; next = NULL; //dispaly the houses in street cout<<"\nEnter number of houses in street "+to_string(n)+"\t"; cin>>n_h; no_of_houses = n_h; head = initialize_houses(n_h); } void display(){ cout<<"\t\t\tStreet "<display(); temp = temp->next; } } }; street * initialize_streets(int n_strt){ street * ret = new street((street_number)); street_number++; street * temp = ret , * t2; for(int j=1;jnext = t2; temp = temp->next; } return ret; } class sector{ public: string name; sector * next; int no_of_streets; street * head; sector(string n){ int n_strt; name = n; next = NULL; //display the streets in sector cout<<"\nEnter number of streets in sector "+n+" \t"; cin>>n_strt; no_of_streets = n_strt; head = initialize_streets(n_strt); } void display(){ cout<<"\t\tSector "<display(); temp = temp->next; } } }; sector * initialize_sectors(int n_sec){ string send=""; sector * ret = new sector(send+sector_number); sector_number++; sector * temp = ret , * t2; for(int j=1;jnext = t2; temp = temp->next; } return ret; } class block{ public: string name; block * next; int no_of_sectors; sector * head; block(string n){ int n_sec; name = n; next = NULL; //display the sectors in block cout<<"\nEnter number of sectors in block "+n+"\t"; cin>>n_sec; no_of_sectors = n_sec; head = initialize_sectors(n_sec); } void display(){ cout<<"\tBlock "<display(); temp = temp->next; } } }; block * initialize_blocks(int n_b){ string send=""; block * ret = new block(send+block_number); block_number++; block * temp = ret , * t2; for(int j=1;jnext = t2; temp = temp->next; } return ret; } class Society{ public: string name,city; int no_of_blocks; block * head; Society(){ string n,c; int n_b; //display the society name cout<<"Enter the name of society\t"; getline(cin,n); //display the city name cout<<"\nEnter the name of city\t"; getline(cin,c); name = n; city = c; //display the society cout<<"\nEnter number of blocks in society\t"; cin>>n_b; no_of_blocks = n_b; head = initialize_blocks(n_b); } void display(){ cout<display(); temp = temp->next; } } }; //main function int main(){ Society society; society.display(); //returning the value return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

How Can we Put this in the Following Program?
In the main function, after creating the Society object and before society.display(), set the owner names of a few houses, and make sure that society.display() displays this information. The main function will look like this:
Pic 1 to Pic 2....
Program:

//header file
#include<bits/stdc++.h>
//using namespace
using namespace std;

char block_number = 'A';
char sector_number = 'A';
int street_number = 1;
int house_number = 1;

class house{
public:
    int name;
    house * next;
    house(int n){
        name = n;
        next = NULL;
    }
    void display(){
        cout<<"\t\t\t\tHouse "<<name<<endl;
    }
};

house * initialize_houses(int n_h){
    house * ret = new house((house_number));
    house_number++;
    house * temp = ret , * t2;
    for(int j=1;j<n_h;j++){
        t2 = new house((house_number));
        house_number++;
        temp->next = t2;
        temp = temp->next;
    }
    return ret;
}

class street{
public:
    int name;
    street * next;
    int no_of_houses;
    house * head;
    street(int n){
        int n_h;
        name = n;
        next = NULL;
        //dispaly the houses in street
        cout<<"\nEnter number of houses in street "+to_string(n)+"\t";
        cin>>n_h;
        no_of_houses = n_h;
        head = initialize_houses(n_h);
    }
    void display(){
        cout<<"\t\t\tStreet "<<name<<endl;
        house * temp = head;
        while(temp!=NULL){
            temp->display();
            temp = temp->next;
        }
    }
};

street * initialize_streets(int n_strt){
    street * ret = new street((street_number));
    street_number++;
    street * temp = ret , * t2;
    for(int j=1;j<n_strt;j++){
        t2 = new street((street_number));
        street_number++;
        temp->next = t2;
        temp = temp->next;
    }
    return ret;
}


class sector{
public:
    string name;
    sector * next;
    int no_of_streets;
    street * head;
    sector(string n){
        int n_strt;
        name = n;
        next = NULL;
        //display the streets in sector
        cout<<"\nEnter number of streets in sector "+n+" \t";
        cin>>n_strt;
        no_of_streets = n_strt;
        head = initialize_streets(n_strt);
    }
    void display(){
        cout<<"\t\tSector "<<name<<endl;
        street * temp = head;
        while(temp!=NULL){
            temp->display();
            temp = temp->next;
        }
    }
};

sector * initialize_sectors(int n_sec){
    string send="";
    sector * ret = new sector(send+sector_number);
    sector_number++;
    sector * temp = ret , * t2;
    for(int j=1;j<n_sec;j++){
        string send="";
        t2 = new sector(send+sector_number);
        sector_number++;
        temp->next = t2;
        temp = temp->next;
    }
    return ret;
}

 

class block{
public:
    string name;
    block * next;
    int no_of_sectors;
    sector * head;
    block(string n){
        int n_sec;
        name = n;
        next = NULL;
        //display the sectors in block
        cout<<"\nEnter number of sectors in block "+n+"\t";
        cin>>n_sec;
        no_of_sectors = n_sec;
        head = initialize_sectors(n_sec);
    }
    void display(){
        cout<<"\tBlock "<<name<<endl;
        sector * temp = head;
        while(temp!=NULL){
            temp->display();
            temp = temp->next;
        }
    }
};

block * initialize_blocks(int n_b){
    string send="";
    block * ret = new block(send+block_number);
    block_number++;
    block * temp = ret , * t2;
    
    for(int j=1;j<n_b;j++){
        string send="";
        t2 = new block(send+block_number);
        block_number++;
        temp->next = t2;
        temp = temp->next;
    }
    return ret;
}

class Society{
public:
    string name,city;
    int no_of_blocks;
    block * head;
    Society(){
        string n,c;
        int n_b;
        //display the society name
        cout<<"Enter the name of society\t";
        getline(cin,n);
        //display the city name
        cout<<"\nEnter the name of city\t";
        getline(cin,c);
        name = n;
        city = c;
        //display the society
        cout<<"\nEnter number of blocks in society\t";
        cin>>n_b;
        no_of_blocks = n_b;
        head = initialize_blocks(n_b);
    }
    
    void display(){
        cout<<name<<"\t"<<city<<endl;
        block * temp = head;
        while(temp!=NULL){
            temp->display();
            temp = temp->next;
        }
    }
};
//main function
int main(){
    Society society;
    society.display();
    //returning the value
    return 0;
}

int main() {
Society society;
society.display();
return 0;
Transcribed Image Text:int main() { Society society; society.display(); return 0;
int main()
{
Society society;
society.set(block,sector,street,house, owner_name);
society.display();
return 0;
Transcribed Image Text:int main() { Society society; society.set(block,sector,street,house, owner_name); society.display(); return 0;
Expert Solution
steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education