Java Reference
In-Depth Information
Write a graphical application that draws a square and a pentagon using
two Polygon objects.
΢G Exercise P7.16. Write a class Chart with methods
public void add(int value)
public void draw(Graphics2D g2)
that displays a stick chart of the added values, like this:
You may assume that the values are pixel positions.
330
331
΢΢G Exercise P7.17. Write a class BarChart with methods
public void add(double value)
public void draw(Graphics2D g2)
that displays a chart of the added values. You may assume that all values
in data are positive. Stretch the bars so that they fill the entire area of the
screen. You must figure out the maximum of the values, and then scale
each bar.
΢΢΢G Exercise P7.18. Improve the BarChart class of Exercise P7.17 to
work correctly when the data contains negative values.
΢΢G Exercise P7.19. Write a class PieChart with methods
public void add (double value)
public void draw(Graphics2D g2)
that displays a pie chart of the values in data . You may assume that all
data values are positive.
Search WWH ::




Custom Search