Question: This program is in Java: Define a class named Color that contains three private int instance variables, representing the red, green, and blue components that
This program is in Java:
Define a class named Color that contains three private int instance variables, representing the red, green, and blue components that make up the color. Each variable has a value between 0 and 255 (inclusive), representing the contribution of that color component to the overall color (for example, a red value of 200 would mean a high amount of red in the color, while a blue value of 50 would represent a low amount of blue in the color). The class also has a private String instance variable that represents the name of the color (e.g., "salmon" or "teal"). The Color class has a constructor that takes three integer arguments, representing the color's red, green, and blue components; it assigns the value null (NOTE: this is a literal value, NOT the string null) to the color name. A second constructor takes three integers and a String as arguments, and assigns them to the appropriate instance variables. Finally, the class has public accessor methods for all four variables.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
