You are on page 1of 4

Javadoc style comments for all functions/methods.

You are not using a vector to store the data (A vector is


used to store the results of queries to the BST using the
visitor pattern - this is fine).
Part I.
Create a C++ class named City that encapsulates the fields shown in this data file.

USCities-100-1.csvDownload USCities-100-1.csv

A specification file (the .h file) and an implementation file (the .cpp file) are required.

All setters and getters are required.

The default constructor is required - initialize all string attributes to "" and all numeric
attributes to 0

A second constructor that will have one parameter - one line of data read from the data
file. This constructor will parse/tokenize the line into the appropriate attributes.

Part II.

Overloaded operators required:

== this will compare two City objects for equivalence of all attributes

!= this will compare two City objects for difference in at least one of the attributes (use
== in this method)

< this will compare the population of two City objects

> this will compare the population of two City objects

+= (int) - to increase the population (increase the population only - don't alter the other
numeric attributes with this operator)

<< this will display the current state of the object in a neat formatted way using cout<<,
you may consider using a horizontal display of information because later you will be
asked to generate reports in table format, to add commas to numeric output you may
use this:

#include <iostream>
#include <string>
using namespace std;
int main() {
int x = 1122334455;
string str = to_string(x);
int n2 = str.length() - 3;
int end2 = (x >= 0) ? 0 : 1; // Support for negative numbers
while (n2 > end2) {
str.insert(n2, ",");
n2 -= 3;
}
cout << str << endl;
}

>> this will allow the user to enter an city into the data structure using cin>>

Part III.
Create a system of menus for querying the data structure (you don't have the data
structure yet, but you can test the menus)

The main menu will consist of these options:

1. Search --- this menu option will launch the Search submenu
2. Generate reports --- this menu option will launch the Generate Reports submenu
3. Maximums and minimums --- this menu option will launch the Maximums and
minimums submenu
4. Edit City data --- this menu option will launch the Edit City submenu
5. Quit --- this menu option will exit the application

The Search menu will consist of these options:

6. Search by zip code --- when a zip code is found in the structure, your program will
display that the city was found and display all of the information about that city
7. Search by state (like MI, TX, CA, etc) ---- when a state is found in the structure,
your program will list the name of all cities in that state, their zip codes and their
county.
8. Search by minimum land area ---- this function will request a minimum land area
from the user and display all cities (all information about the city is fine here) that
covers that minimum number of square miles
9. Return to main menu – self-explanatory

The Generate Reports menu will consist of these options:

10. List all cities --- this will list all cities and all information about the cities in a well-
formatted table
11. List all cities and their population density --- display the city name, population and
land area
12. List all cities by time zone ---- display a list of time zones, allow for user entry ----
display the city name, state and zip code
13. Post order traverse --- this will perform a post order traversal of your BST, display
the cities in a well-formatted table
14. Return to main menu – self-explanatory

The Maximums and minimums menu will consist of these options:

15. Maximum land area --- display the city name, state, land area, population
16. Maximum population --- display the city name, state, land area, population
17. Minimum land area --- display the city name, state, land area, population
18. Minimum population --- display the city name, state, land area, population
19. Maximum population density --- display the city name, state, land area, population
20. Minimum population density --- display the city name, state, land area, population
21. Return to main menu --- self-explanatory

The Edit City menu will have the following options:

22. Edit population --- this will allow the user to enter a city name and a value to edit
the population by, change the population - display the old and new
23. Edit land area ---- this will allow the user to increase or decrease the size of the
city - allow the user to enter the city and a value to increase or decrease the land
area by --- display the old and new
24. Return to main menu

Part IV.
1. Create a linked binary search tree of your City objects (not a vector!). You may
choose to use the BinarySearchTree and associated files attached.

2. Add two functions to your BSTInterface: preorderTraverse() and postOrderTraverse().


You will note that the preorderTraverse() is done for you in the verification process for
removing nodes from the tree. You will write a postOrderTraverse() using
inorderTraverse() and preorderTraverse() as models. The postOrderTraverse() will be an
additional menu option in the Generate Reports menu.

3. Move all menus to a file outside of main().

4. Add error trapping to your menus - if the menu only has options 1 - 4, then your user
should be required to stay in that menu until a valid option is entered.

5. You are completing the contains() method in the BinarySearchTree to search for a
City object. This requires that the City object be entered in its entirety by the user. The
other search methods are NOT in the BSTInterface since they are not BST standard
functionality.

Part V
Using the Visitor pattern complete the tasks dictated by the menu options in Part III.

Deliverables (zipped into a single folder

• City.h
• City.cpp
• USCities-100-1.csv
• main.cpp
• menus.cpp (or menus.h, whichever you've chosen is fine here)
• BSTInterface.h
• Node.h
• BST.h (the binary search tree file)

You might also like