Help with simple bar chart program
Hi, I was assigned a very vague program by my professor. Long story short, we were basically taught half of the material and expected to complete this program.
What we were asked to do was to design a bar chart with an average line, and on this bar chart we were supposed to have the data that was greater than the average have bars above the average line, and the data below the average with bars below the line. He also instructed us (in a series of emails, most of which contradicted the emails before them or what he taught in class) to create the following things:
an auxiliary class called BarWithAverage (detailed below)
The program I have so far is as follows.
I'm stuck, and I'd really like a nudge in the right direction. This is only my second semester programming.
What I'm really confused on is how we're supposed to use the class BarsWithAverage to actually calculate an average using the array we made with createBars. They're part of two separate classes, and I'm following his exact instructions. How can I actually do something like that?
I'm not looking for someone to give me the answer, I really just want a nudge. I've spent the last 4 days stuck in the same spot and researching how to do this, and it hasn't been until today that I've finally broken down and asked online. When I confronted the professor about this, he asked me how I expected to learn if he taught us everything. The TA also hasn't been available, so my classmates and I have pretty much been alone on this. (sorry for the rant)
Are these class and constructor signatures provided in this way? If so, I don't see any purpose to adding these private methods to BarWithAverage either. Since they can't be called outside of the class, nor is the BarWithAverage provided with any information regarding the averages of other items or a file in which it can read, it has no practical use within the BarWithAverage itself. That really makes more sense to use on the BarChartWithAverage given what you have here for the two classes and their construction. Now if you have other setters such as taking the average or giving it the data array, then sure that would be alright in the BarWithAverage.
What I'm trying to figure out looking at this is if the BarWithAverage is to paint itself, or simply return data. Since drawBars isn't provided, we cannot tell if it intends to paint itself or simply describe itself to the BarChartWithAverge.
So the only way I can see the BarWithAverage actually making use of these private methods is if you provide it with a graphics to paint on, the entire dataset available (or a file or whatever to get them from), and then you can paint with the class. To me, these still seem like they should be on the BarChartWithAverage class (non-static of course; the drawBars you have is static). This way it can iterate an array of BarWithAverage objects and paint accordingly.
I think you'll need to get more clarification on what these classes are responsible for doing.
|All times are GMT +1. The time now is 05:53 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.