Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose there is a class in Java called RGB. This class is used to store the amo

ID: 3691999 • Letter: S

Question

Suppose there is a class in Java called RGB. This class is used to store the amount of red, blue, and green light used (these are int values) to paint a color on the screen using graphics. Determine whether each of the method signatures below should be a class method or an instance method, based on the signature. Do not try to get this by looking at the Color class in Java—I’ve changed the method signatures.

void setRed(int red, RGB color)

The method changes the amount of red stored in the RGB object color to red.

RGB setGreen(int green)

The method creates a new RGB object that has the given amount of green and no red or blue components.

int[] toArray(RGB color)

The method converts the RBG object color to an array of three integers (red at index 0, green at index 1 and blue at index 2).

int[] toArray()

The method converts this RGB object to an array of three integers (red at index 0, green at index 1 and blue at index 2).

      

void setBlue(RGB color, int blue)

The method changes the amount of blue in the RGB object color.

int getBlue()

The method returns the amount of blue in this RGB object.

void lighter(RGB color)

The method makes this RGB object color lighter.

void decode (String color)

This method takes a String with the following format:“(127, 53, 27)” and sets the implicit object’s colors.The String above would change the RGB object to have red = 127, green = 53, and blue = 27

void darker()

The method makes this RGB object darker.

void setRGBFromHSV(int hue, int saturation, int value)

The method changes this RGB object to have red, blue, and green values converted from the hue, saturation, and value.   Hue, saturation, and value is another way of describing a color.

Explanation / Answer

Class Mathod :
void setRed(int red, RGB color)
void setBlue(RGB color, int blue)
int getBlue()
RGB setGreen(int green)


Instance Method :
int[] toArray(RGB color)
int[] toArray()
void setRGBFromHSV(int hue, int saturation, int value)
void darker()
void decode (String color)
void lighter(RGB color)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote