must be solved with java
In this exercise we will write a simple app for displaying
textual information using charts.
Given the Abstract Class Chart which represents a chart:
public abstract class Chart {
private ArrayList<Double> data;
private ArrayList<String> labels;
public Chart(ArrayList<Double> data,
ArrayList<String> labels) {
this.data = data;
this.labels = labels;
}
public abstract void draw(Graphics g, int x, int y, int width,
int height);
}
The abstract Chart class contains two attributes: the data list
contains the data that needs to be displayed, and the labels list
contains the data names
For example, if we are given the average price of avocados in
each quarter of 2022, the information will look like this
{3.5, 4.6, 5.3, 3.6} and the labels will look like this:
{“querter1”, “quarter2”, “quarter3”, “quarter4”}
That is, in the first quarter (quarter1) the average price was
3.5, in the second quarter it was 4.6 and so on.
The class contains an abstract method called draw. The method
accepts as parameters the Graphics with which you draw, and the
data of the drawing area (upper left corner and width and height of
the surface). The method will draw the diagram in this area using
g.
Write a class called Column that will be exstends from
the abstract Chart class and represent a stick chart. The labels
will appear on the x-axis and the values on the y-axis. For
example, the stick chart for avocado data would look like
this
6 5 st 3 2 1 Quarter1 Quarter2 Quarter3 Quarter4
must be solved with java In this exercise we will write a simple app for displaying textual information using charts. Gi
-
- Posts: 43759
- Joined: Sat Aug 07, 2021 7:38 am