question archive In many languages (including Java), you can form a color by specifying certain amounts of red, green, and blue, with each color's amount ranging from 0% to 100%

In many languages (including Java), you can form a color by specifying certain amounts of red, green, and blue, with each color's amount ranging from 0% to 100%

Subject:Computer SciencePrice: Bought3

In many languages (including Java), you can form a color by specifying

certain amounts of red, green, and blue, with each color's amount ranging from 0% to 100%. For example, to specify purple, you could use this code rgb(100%, 60%, 100%) The rgb stands for red, green, and blue. With 100% for red and blue, the resulting color is purple. In the following Rgb and RgbDriver class skeletons, replace the lines with appropriate code such that the program operates properly. More specifically: In the Rgb class, provide a method definition for the setRed method such that setRed can be called as part of a method-call chain. In the RgbDriver class, provide a single statement that chains calls to the setRed, setGreen, setBlue, and display For your method-call arguments, pass 100 to setRed, 60 to setGreen, and 100 to setBlue. With those argument values, your method-call-chaining statement should print this: rgb(100%, 60%, 100%) public class Rgb { private int red; private int green; private int blue; public Rgb setGreen(int green) { this.green = green; return this; } // end setGreen public Rgb setBlue(int blue) { this.blue = blue; return this; } // end setBlue public void display() { System.out.printf("rgb(%d%%, %d%%, %d%%)n", this.red, this.green, this.blue); } // end display } // end Rgb class public class RgbDriver { public static void main(String[] args) { Rgb rgb = new Rgb(); } } // end RgbDriver class

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Related Questions