Question: A Color class has a method getColorName that returns a String corresponding to the common name for the color, e.g., yellow, blue, white, etc.

A Color class has a method getColorName that returns a String corresponding to the common name for the color,

A Color class has a method getColorName that returns a String corresponding to the common name for the color, e.g., yellow, blue, white, etc. If there is no common name associated with the color, null is returned. The class, AlphaChannelColor-a subclass of Color-has an int instance variable, alpha, containing the alpha channel value, representing the degree of transparency of the color. Write the method getColorName of AlphaChannelColor, which overrides the method in the Color class. AlphaChannelColor's getColorName should return the name of the color (obtained from the getColorName method of Color) prefixed with the word "opaque" if the alpha value is less than 100, "semi-transparent" if the alpha value is otherwise less than 200, and "transparent" otherwise. Separate the prefix from the color name by a blank. If the color has no name, the method should return "opaque color," "semi-transparent color," or "transparent color," according to the same alpha values as above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Based on the instructions in the image we want to write a method getColorName that overrides the met... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!