Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 3: A Bar Chart Racer! Points: 35% Overview The goal of this part of the assignment is to implement an animated program that shows

Part 3: A Bar Chart Racer!
Points: 35%
Overview
The goal of this part of the assignment is to implement an animated program that shows how some data changes over time. You will repeatedly read data from a file and display it using the Chart class you have implemented in Part 2.
Data Files
Data will be read from one of the following files (or any other file that follows the same format):
cities.txt: The most populous cities in the world over time.
countries.txt: The most populous countries in the world over time.
baby-names.txt: The most popular baby names in the USA over time.
brands.txt: The most valuable brands over time.
Each of these files contains data grouped by date. You will represent each group of data (i.e. the data for every date) using a chart.
Note the following:
The first line in the file is the chart title. This title is the same for all the charts that will be created from this data file. The title is guaranteed not to have spaces.
For each date, information is formatted as follows:
The number of bars in the chart (n) appears on a separate line.
Each of the following n lines has the following separated by spaces:
The date. This will be used as the caption of the chart.
This is an integer that is repeated as-is for all the n bars.
The label of the bar.
This is a string that is guaranteed not to have any spaces.
The length of the bar.
This is an integer that is guaranteed to be non-negative.
The following figure illustrates the format:
Visualize and Animate
Write a program to perform the following:
Read from the user the name of the data file.
Read from the file the title of the chart.
Repeat the following while there is still data in the file. Each iteration is for one chart.
Read the number of bars in the chart (call it n).
Create an array of Bar objects of size n.
For each Bar object:
Read the caption (and ignore it, or save it for later use).
Read and set the label and length of the bar.
Set the color of the bar to GREEN (or any other color of your choice).
Create a Chart object using the created bars. Sort the chart.
Clear the screen. Use system("CLS") on Windows and system("clear") on MacOS, Unix, Ed, Repl.it, OnlineGDB, etc.
Show the top 10 bars in the chart with the appropriate caption and a maximum size of 70.
Pause the computer for a short while.
- On Windows, you can include and then use Sleep(delay).
- On Mac/Unix, you can include and then use usleep(delay).
Delete the created array of bars.
The following videos are examples for how running the program should look like:
Using cities.txt: video link.
Using baby-names.txt: video link.
Using countries.txt: video link.
Using brands.txt: video link.
The colors are arbitrary. You can pick any color you like.
Running the program on Ed, Repl.it, OnlineGDB, or any other online IDE, will cause flickering. The above videos are smooth because they were produced by running the program locally on the machine (you can do that too!)
Implementation Requirements
All of your code must in the file named Racer.cpp. You must also copy your implementation for parts 1 and 2 into Bar.cpp and Chart.cpp (without the main() functions).
You are allowed to define functions beside main() in Racer.cpp.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

Students also viewed these Databases questions