Solved

Creating a Color Class?

Posted on 2008-10-30
2
929 Views
Last Modified: 2013-11-23
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};

  }
}
0
Comment
Question by:April_Denise
2 Comments
 
LVL 7

Accepted Solution

by:
humanonomics earned 125 total points
ID: 22847852
Can you please re-phrase the question ? It is a bit confusing.
0
 
LVL 5

Expert Comment

by:muktajindal
ID: 22848142
Use desired color by accessing array crayonColors[].
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now