must be solved with java i sent this question 3 times and they solved it in the same way the class pie must be extends f
Posted: Fri Jun 10, 2022 11:55 am
must be solved with java
i sent this question 3 times and they solved it in the same way
the class pie must be extends from the abstract Chart class
please pay attention for every single word and don't solve this question like they do before
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 Pie that will be inherited from the abstract Chart class and represent a pie chart. The draw method will draw the diagram as a circle, with each figure appearing as a cut in a different color and relative to its size. Below the color chart. For example, this is what the pie chart for avocado data would look like:
i sent this question 3 times and they solved it in the same way
the class pie must be extends from the abstract Chart class
please pay attention for every single word and don't solve this question like they do before
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 Pie that will be inherited from the abstract Chart class and represent a pie chart. The draw method will draw the diagram as a circle, with each figure appearing as a cut in a different color and relative to its size. Below the color chart. For example, this is what the pie chart for avocado data would look like: