Skip to content

displayMap()

Omary, Salma edited this page Nov 5, 2022 · 4 revisions

display.cpp contains 2 void functions: displayMap and displayPollutedMap. The displayMap function has 5 parameters: the first being of type Map and the rest being ints representing coordinates within the map. A temp variable of type 2D Zone vector is created and initialized to be equal to the map grid. A for loop then iterates through the temp map grid, going from the top left to right (a nested for loop is also used to accomplish this iteration process). Another temp variable, tempZone, of type zone pointer is initialized to the current location being looked at in the iteration. Once tempZone->getType() is called to get the type of zone in the given location, the loop checks if the zone is residential, commercial, or industrial, and proceeds to output the population rather than the zone variable if population is > 0. In the case of an unpopulated zone, the letter/variable representing the zone is output.

Clone this wiki locally