Answered step by step
Verified Expert Solution
Question
1 Approved Answer
do this in C++ thank you This lab includes 34 points in aggregate. The details are given in the following 1 Class City First, let's
do this in C++ thank you
This lab includes 34 points in aggregate. The details are given in the following 1 Class City First, let's define class city in header file city.h, with the following details 1. Each City has the following data components: The name of the state: name as a string, and The population of the state: population as an unsigned integer. Each of the aforementioned data components must be hidden from the class user (2 points). 2. Define setter function void setName(string name) in inlined form. Since the function pa- rameter has the same name as the data component name, you need to use this pointer to refer to the data component name within the body of the function (2 points). 3. Define setter function void set Population (unsigned int population) in inlined form Since the function parameter has the same name as the data component population, you need to use this pointer to refer to the data component population within the body of the function (2 points) 4. Define getter functions get Name and get.Population accordingly in inlined form (4 points) 5. Define default constructor City) that sets name to N/A, and population to o, in inlined form (2 points) 6. Define a second constructor City(string name, int population) that sets data compo nents name and population using the input arguments. Again, since the parameters and data components have the same name, you need to use this. Define this constructor in inlined form, as well (2 points) 2 Class Cities Second, let's define class Cities in header file cities.h and source file cities.cpp. The header file includes the definition of the class, and the source file includes the definition of class functions. The details are as follows: 1. Each Cities object includes a vector of City objects. Name this vector citylist, and make it hidden to class users. Note that you need to include city.h header file in cities.h, in order to use class City (2 points) 2. List the two public functions for this class void readcities () and void printcitylist() in the definition of class Cities (2 points) In cities.cpp file, define the functions listed in the previous step. In this file, you must include file cities.h. Details are as follows: 3. Function readcitien() iteratively reads city name and population from standard input and puts them in the citylist. Continue reading city information until user enters X (3 points) 4. Punction printCityList() iterates through the vector citylist and prints the name and population of each city, separated by '' (3 points) 3 Claw State classe le 3 1. A cities dels comptateities elective 2. At veld tecites afh. They ciasto 1 Avalid pri Statele to This funcio otprintcity face print 4 Main function Demented the 1. Rondanti 2. Od to the consume Rally made by calling reasotectie of cymund ti by it The police Bate California ter elty and poslation to end, the City Longelea Population City sarac Populatie 0000 City Scato at 0000 City: Stock Population 00000 City The state calitarnia te the following cities/ppulations Losgels 1000000 Banfrancisco 00000 Sacramenta 500000 Bota 300000 Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started