April_Denise
asked on
Creating a Color Class?
I have to create a color class called Crayon that represents one crayon of a particular color and lenght/height..and design and implement a program that draws a box of crayons....I have the colors, but how to implement them as colors?
import java.awt.Color;
import javax.swing.JApplet;
import java.awt.*;
public class Crayon extends JApplet
{
public void paint (Graphics page)
{
int crayonShapeX[] = { 0, 2, 10, 15, 23, 25, 25, 0 };
int crayonShapeY[] = { 15, 15, 0, 0, 15, 15, 45, 45 };
private Color crayonColors[] = {
Color.blue, Color.cyan, Color.darkGray,
Color.gray, Color.green, Color.magenta,
Color.orange, Color.pink, Color.red,
Color.white, Color.yellow};
}
}
import java.awt.Color;
import javax.swing.JApplet;
import java.awt.*;
public class Crayon extends JApplet
{
public void paint (Graphics page)
{
int crayonShapeX[] = { 0, 2, 10, 15, 23, 25, 25, 0 };
int crayonShapeY[] = { 15, 15, 0, 0, 15, 15, 45, 45 };
private Color crayonColors[] = {
Color.blue, Color.cyan, Color.darkGray,
Color.gray, Color.green, Color.magenta,
Color.orange, Color.pink, Color.red,
Color.white, Color.yellow};
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use desired color by accessing array crayonColors[].