The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing other colors.
When you mix two primary colors, you get a secondary color, as shown here: When you mix red and blue, you get purple When you mix red and yellow, you get orange When you mix blue and yellow, you get green
Your challenge is to write a class called ColorMix.java and TestColorMix.java.
ColorMix.java accepts three Strings: color1, color2, color3.
The program must return to the user the colors entered, the result of mixing the colors e.g. purple, orange, or green. The class must also tell the user if no color mix is found and if the user entered similar colors.
The ColorMix.java must include the following:
1. Final constants: String BLUE = “blue”; String RED = “red”; String GREEN =”green” (3 points)
3. Constructs (10 points each) public ColorMix() public ColorMix(String col1, String col2)
4. Mutators (5 points) public void setColor1 (String col1) public void setColor2 (String col2)
5. Accessors (5 points) public String getColor1 () public String getColor2 ()
6. A method public String mixColor() . The method uses if statements in conjunction with logical operators (&&, ||, == and != ) to prints the outcome of mixing the colors. The outcome includes 5 results: purple, orange, green, entered similar colors, no color combination possible. (35 points)
Here are some hints:
if (color1.compareTo(color2)==0) System.out.print(“entered same colors”);