On This Page
Overview
During this assignment, you will:
- Code the implementation of a bar-charting class
- Use an object of the class to draw a bar chart
- Read data from a file into a vector
Background Information
A bar chart, also known as a bar graph, is a chart with rectangular bars of lengths proportional to the magnitudes or frequencies of what they represent. Bar charts are used for comparing two or more values. For more information, see: Bar chart
^ top
Specifications
- Develop a bar chart class by implementing all the member functions of the following interface:
class BarChart {
public:
/**
Constructs a BarChart with no data.
*/
BarChart();
/**
Constructs a BarChart and reads data from the
specified file.
@param fileName The name of the file from which
to read.
*/
BarChart(string fileName);
/**
Displays the BarChart in the graphics window.
*/
void draw() const;
/**
Reads plot data from the specified file.
@param fileName The name of the file from which
to read.
*/
void read(string fileName);
private:
vector<double> data;
};
- Implement all the functions as specified in the interface.
- Use a vector to store the data for the chart to display.
- In your
ccc_win_main() function, create a BarChart object from your class, load the file "plot.txt" and display the data from the file as a bar chart centered in the graphics window.
- All input must be from the
plot.txt file. Do NOT use any keyboard input statements, like cin or cwin.get_string(), in this assignment or you will get a low score.
- The plot file must be a simple list of any number of
double values like the example: plot.txt.
- Do not forget to document all the code and follow all the other style rules we have covered so far. Though I have put a few comments in the starter code, you are responsible for the accuracy and completeness of the final comments.
- The name of the source code file must be
chart.cpp and all your code must be in this file.
Be careful of the spelling, including capitalization, as you will lose points for a misspelled name.
- Submit your files to WebCT as explained in the section of this document: What to Turn In.
Example Program
You can see an example of how the program operates by downloading and running the executable file: chart.exe. In addition, you will want to download the example data files listed below.
Hints:
- Remember to always
#include standard libraries first and #include other files after the standard libraries.
- Find the minimum and maximum values in the data. Set the coordinates of
cwin so that the x-range equals the number of bars and the y-range goes from the minimum to the maximum.
- You can include a slight offset around the bars to improve the way they look.
^ top
Extra Credit
Adding the following are worth extra credit points:
- Complete the assignment using pair programming. (1 point)
- Display the numerical data for each bar near or inside the bar. (2 points)
Make certain that your README.txt file describes any extra credit attempted.
^ top
Grading Criteria
The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.
Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.
For information on grading policies, including interpretation of scores, see the course information page.
Program Compilation
- 4: Source code compiles with no errors or warnings
- 2: Source code compiles with warnings
- 0: Does not compile or wrong file turned in
Functionality
- 10: Demonstrates mastery of the assignment
- Applies concepts from the lessons appropriately
- Meets all specifications (see above) with particularly elegant solutions
- Runs to completion with no abnormal error conditions
- Generates correct output given correct input
- Behaves in a reasonable way in response to incorrect data
- 8: Has all the functionality expected of the assignment
- Demonstrates many techniques from the lesson
- Attempts to meet all specifications (see above)
- Implementation seems more complicated than necessary.
- May have one minor error
- 6: Has most of the functionality expected of the assignment
- Demonstrates some techniques from the lesson
- Attempts to meet all but one of the specifications (see above)
- Implementation seems excessively complicated.
- May have 2-3 minor errors
- 4: Has some of the functionality expected of the assignment
- Demonstrates some techniques from the lesson
- Attempts to meet at least 1/2 of the specifications (see above)
- Implementation seems excessively complicated.
- May have more than 3 minor errors
- 2: Serious functional problems but shows some effort and understanding
- Attempts to meet less than 1/2 of the of the specifications (see above)
- Has a major error or many minor errors
- Implementation seems very convoluted
- Demonstrates few techniques from the lesson
- 0: Does not execute
Program Style
- 4: Code is well-documented including:
- Name, date, and program description in file comment block
- Follows specified format for file comment block
- Has a function comment block for all function declarations following the specified format
- Proper use of spaces around operators
- No tab characters are present in the source code
- As described in How To Document and Organize C++ Code
- Correct file name used
- 3: Code has a minor documentation error
- 2: Code has some documentation errors
- 1: Code has many documentation errors
- 0: No apparent attempt to write documentation comments
REAME.txt File
- 2: README.txt file submitted with specified information included
- 1: README.txt submitted but some information was not included
- 0: No README.txt submitted
Maximum Score: 20, plus extra credit
^ top
What to Turn In
Submit your assignment following the instructions for homework. Include the following items for grading:
README.txt file
chart.cpp
^ top
Home
| Blackboard
| Announcements
| Day Schedule
| Eve Schedule
Course info
| Help
| FAQ's
| HowTo's
| Links
Last Updated: December 03 2007 @15:21:11
|