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.

Complete the following file:

Chart.java

Use the following files:

ChartComponent.java

import javax.swing.JComponent;
import java.awt.Graphics;
import java.awt.Graphics2D;

public class ChartComponent extends JComponent
{
   public void paintComponent(Graphics g)
   {  
      Graphics2D g2 = (Graphics2D) g;
      Chart c = new Chart(getWidth(), getHeight());
      c.add(10);
      c.add(30);
      c.add(80);
      c.add(30);
      c.add(20);
      c.add(200);
      c.add(100);      

      c.draw(g2);
   }
}

ChartViewer.java

import javax.swing.*;

/**
   Tester class to display a stick chart.
*/
public class ChartViewer
{  
   public static void main(String[] args)
   {
      JFrame frame = new JFrame();

      final int FRAME_WIDTH = 300;
      final int FRAME_HEIGHT = 300;

      frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
      frame.setTitle("ChartViewer");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      ChartComponent component = new ChartComponent();
      frame.add(component);

      frame.setVisible(true);
   }
}