Description
A vast amount of information about the households that make up our population has been collected via a recent census, and we have been asked to assist local government in processing this data by providing a tool for analyzing the households that exist within certain “wards” of the city. We will be using C++ objects to represent both the households within a ward and the ward itself.
For this project I have given you two of the files that you will be using, so you should begin by copying them into your working directory. These files are housebold.h and main.cc. You should also copy the data file, households.txt.
The first task is writing the function implementations for the Household class. I have given you the header file for this class which has private variables for.
• The name of the head of the household (a string – with spaces, requiring getline)
• The address of the household (a string – with spaces, requiring getline) – no city or zip
• The number of people living in the household (an int)
• The total household income. (an int – we won’t worry about the cents)
The class has a full set of accessor and mutator functions as well as input and output functions and overloaded << and >> operators.
You are to write the implementations for this class in a separate .cc file.
You should compile and test this class with a short driver program, a driver program that will not be part of your final submission. (Basically it declares a single house hold and tests each member function.)
Next develop a class that will allow the storage of a group of households that exist in an area known as a “ward”. Each ward will be capable of holding 200 households, although most will be significantly smaller. (This SIZE should be declared as a static const as we have seen in the book.) This array of households will generally be a partially filled array.
Facilities that the ward class should offer include:
• Input an additional household into the ward
• Output all the households in the ward
• Removal of a household in case the people have moved away.
• Find a household by the name
• Find the household with the largest income
• Find the average income
• Find the average number of people in each household
• Sort by income
• Sort by name
These options are going to be offered to the user in the menu in the main, a main which I have written for you. It’s available on Blackboard or at ~jdolan/cs2401/projects/project1 (You must use the main that I have written – you can comment out pieces of it as you develop the class.)
Finally, since the task of typing in this many households is arduous, we will use file storage to load the sample ward that we are using to test our new class. When the program is started it should load information from a data-file, and when it shuts down it should rewrite the data-file with the updated list of households. I have provided you with an initial data file, called households.txt. Your final program should be able to load the information in this file into households in the ward object, and then when it leaves it will rewrite this same file, saving all the changes to the data.
There will be a total of six files in your project submission, two for the household class, two for the ward class, an application file, and the data file. Submit your program by attaching the files in the appropriate Blackboard assignment.
This project is due at 11:59 on Tuesday, July 7th. (Generally projects will be due on Mondays, but I have allowed an extra day here because of the holiday.)