1. Engineering
  2. Computer Science
  3. write in java write a class called rgbcolor that has...

Question: write in java write a class called rgbcolor that has...

Question details

Write in JAVA

Write a class called RGBColor that has a final String field which contains either “RED”, “GREEN”, or “BLUE”. Provide a constructor that takes an int argument that assigns the

String field as follows:

0: “RED”

1: “GREEN”

Anything else: “BLUE”

Provide another constructor that takes a String argument. If the argument is not “RED”, “GREEN”, or “BLUE”, the string “BLUE” is assigned to the String field.

Provide a constructor with no arguments that assigns the string “BLUE” to the String field

Write a driver class whose main method creates several RGBColor objects using all three constructors. Print the String field of each object using its accessor.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution