Homework7 Due: Thurs, April 30

advertisement
CSCE 2004 - Homework 7
Due Date - Thursday, April 30, 11:59pm
This assignment MUST be done individually
1. Problem Statement:
The goal of this programming assignment is to give students experience using container classes
in C++. Your task is to write a program that will store information about the countries in a North
America, specifically their name, GDP and Population, allow users to add additional countries to
the continent as well as make several queries about continent information.
You have been provided with five files: Country.h, Country.cpp, Continent.h and Continent.cpp
and hw7.cpp. Country.h as well as Country.cpp are completed. You may not edit either of
these files (exception: you can make the Print in County.cpp look prettier if you want).
However, you will need to edit Continent.h, Continent.cpp and hw7.cpp to complete the
requirements listed below. You are also given a file of data called "list.txt". It contains the
following information for several countries in North America, one per line: GDP in millions,
population, and name.
To download all the files to your virtual machine:
Open a browser inside your virtual machine (e.g., Firefox is available under the
Applications menu)
Click on the link for hw7.tar
Select Save File
Open the Terminal on your VM
Move hw7.tar to where you want it to be: "mv Downloads/hw7.tar ." where . means the
current directory or "mv Downloads/hw7.tar 2004" if you have a subdirectory called
2004 with your work.
Change directory to the same directory as hw7.tar with the cd command
Untar (extract) the files: "tar xvf hw7.tar"
The files are now in the newly created hw7 directory; cd into hw7 and ls to confirm you
have them all
Run "make" to compile and "./hw7" to run the downloaded program
Continent.h:


Each method of the Continent class has been listed as well as the private variables.
However, some methods are missing their parameters. Based on the comments above
each method in the Continet.cpp, fill in the appropriate parameters for each method in the
.h file. Remember, not every method requires parameters. The parameters you place in
the .h file must also be used in the corresponding .cpp file.
o Example:
The Country.h file is 100% finished. Below is a completed method from the
Country.h file
void GetCountryInfo(string &Name, int &Population, float &GDP);
However, imagine that it looked like this:
void GetCountryInfo(); //see Country.cpp to determine if parameters are needed
Your goal would be to fill in the parameters based on the comments above the
GetCountry info function in the .cpp file. The description is below:
//----------------------------------------------------------// Name: GetCountryInfo
// Purpose: Gets all the country's info
// Arguments: ??
// Returns: void
//----------------------------------------------------------Based on the name and comment for the function, I would guess that this was an
accessor whose goal was to get all of a Country's private instance variable values.
So, I would look at the number an type of the instance variables in Country.h and
create a reference parameter to hold the values of each. I would then change the
prototype to: void GetCountryInfo(string &Name, int &Population, float
&GDP); in the .h and the .cpp; compile. After it compiles, I would add in the
body for GetCountryInfo and test with a call from the main program:
o string Name; int Pop; float GDP; Country Foo;
o Foo.GetCountryInfo (Name, Pop, GDP);
o // print Name Pop GDP
Continent.cpp:
Work on the methods on at a time as follows:




Add the missing parameters in the .h file and the .cpp file
compile and run the program
Implement the method based on the comments above it.
call the method with several different parameters in the main program to test
hw7.cpp:

Inside of the loop (in main) use either if statements or a switch to make the correct
function calls
Bonus (5pts Each):



Implement the copy constructor of the Continent class.
Create an additional method in the Continent class that utilizes information stored in the
Country class
Create another additional method in the Continent class that utilizes information stored in
the Country class
2. Design:
For this assignment, the first design task is to decide which methods in the .h file require
parameters. Your second design decision should be how to check for errors in each method.
3. Implementation:
Since you are starting with a semi-completed portion of code it is extremely important to
understand the code that has already been provided. Since it can be difficult to understand
someone else’s code it is extremely important to develop your code incrementally. This way
your program does something even if it is not complete. Begin by implementing the simplest
method first (e.g., AddCountry). For examples on containers classes see Lab 12.
4. Testing:
Test your program to check that it operates correctly for all of the requirements listed above. Try
your program with several input values, and save your testing output in text files for inclusion in
your project report. This is worth 10% of the project grade. Be sure to have MULTIPLE tests.
5. Documentation:
When you have completed your C++ program, write a short report using the project report
template describing what the objectives were, what you did, and the status of the program. Does
it work properly for all test cases? Are there any known problems? Save this report to be
submitted electronically.
6. Project Submission:
In this class, we will be using electronic project submission to make sure that all students hand
their programming projects and labs on time, and to perform automatic analysis of all programs
that are submitted.
Rename your program, testing, and documentation files
123456789.Continent.cpp,
123456789.Continent.h,
123456789.hw7.cpp,
123456789.hw7.txt (typescript testing file),
123456789.hw7.docx
using your UAID number in place of 123456789, and go the Blackboard site for this class
and submit these five files. You do not need to upload Country.h and Country.cpp since they
should be unchanged.
The dates on your electronic submission will be used to verify that you met the due date above.
All late projects will receive reduced credit:




10% off if less than 1 day late,
20% off if less than 2 days late,
30% off if less than 3 days late,
no credit if more than 3 days late.
You will receive partial credit for all programs that compile even if they do not meet all program
requirements, so handing projects in on time is highly recommended. If your program does not
compile, the correctness section of the project score will be a 0. This leaves 50 possible points
for the project design, implementation, testing and report.
7. Academic Honesty Statement:
group projects have been explicitly assigned.
are NOT allowed to distribute code to each other, or copy code from another
individual or website.
ask the instructor and/or GTAs for assistance.
This course will be using highly effective program comparison software to calculate the
similarity of all programs to each other, and to homework assignments from previous
semesters. Please do not be tempted to plagiarize from another student.
Violations of the policies above will be reported to the Provost's office and may result in a ZERO
on the programming project, an F in the class, or suspension from the university, depending on
the severity of the violation and any history of prior violations.
Download