Change the car viewer program in Section 3.9 to make the cars appear in different colors. Each Car object should store its own color. Supply modified Car and CarComponent classes.

Here is a sample program output:

.

Complete the following files:

Car.java

CarComponent.java

Use the following file:

CarViewer.java

import javax.swing.*;

public class CarViewer
{
   public static void main(String[] args)
   {
      JFrame frame = new JFrame();

      frame.setSize(300, 400);
      frame.setTitle("Cars");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

      frame.setVisible(true);
   }
}