Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public class Main { /** * This application generates an html page that displays different colors. */ public static void main(String args[]) { Color139 cc1;

public class Main { /** * This application generates an html page that displays different colors. */ public static void main(String args[]) { Color139 cc1; Color139 cc2; Color139 cc3; Color139 cc4; Color139 cc5; Color139 cc6; Color139 cc7; Color139 cc8; Color139 cc9; System.out.printf("

 "); out("color BLACK", Color139.BLACK); out("color RED", Color139.RED); out("color GREEN", Color139.GREEN); out("color YELLOW", Color139.YELLOW); out("color BLUE", Color139.BLUE); out("color MAGENTA", Color139.MAGENTA); out("color CYAN", Color139.CYAN); out("color WHITE", Color139.WHITE); System.out.printf(" "); out("color RED+GREEN", Color139.RED.add(Color139.GREEN)); out("color RED+YELLOW", Color139.RED.add(Color139.YELLOW)); out("color WHITE-CYAN", Color139.WHITE.sub(Color139.CYAN)); System.out.printf(" "); cc1 = new Color139(34, 54, 189); out("color cc1{34,54,189}", cc1); cc2 = new Color139(128, 32, 64); out("color cc2{128,32,64}", cc2); System.out.printf(" "); out("color dark BLUE", Color139.BLUE.darken()); out("color dim BLUE", Color139.BLUE.dim()); System.out.printf(" "); cc3 = Color139.BLUE; cc3 = cc3.add(Color139.GREEN); System.out.printf ("Does BLUE + GREEN == CYAN? %s ", String.valueOf(cc3.equals(Color139.CYAN))); System.out.printf(" "); cc4 = new Color139(0,64,0); out("color cc4{0,64,0}", cc4); for (int ii = 0; ii  "); } /** * This method outputs HTML for a color's string and the color * itself along with a comment describing what the color is. */ private static void out(String descript, Color139 theColor) { System.out.printf("%-30s is %s in hex and looks like this: " + "  ", descript, theColor.toString(), theColor.toString()); } } 

------------------------------------------------------------------------------------------------------------------

public class Color139 {

public static final Color139 BLACK = new Color139(0,0,0); public static final Color139 RED = new Color139(255,0,0); public static final Color139 GREEN = new Color139(0,255,0); public static final Color139 YELLOW = new Color139(255,255,0); public static final Color139 BLUE = new Color139(0,0,255); public static final Color139 MAGENTA = new Color139(255,0,255); public static final Color139 CYAN = new Color139(0,255,255); public static final Color139 WHITE = new Color139(255,255,255);

private int red; // Red component of the Color139 object private int green; // Green component of the Color139 object private int blue; // Blue component of the Color139 Object

public Color139(int redComponent, int greenComponent, int blueComponent) { // MAKE ME }

public String toString() { String redStr; // red component hex value as a string String greenStr; // green component hex value as a string String blueStr; // blue component hex value as a string

redStr = Integer.toHexString(this.red); if (redStr.length() == 1) redStr = "0" + redStr; greenStr = Integer.toHexString(this.green); if (greenStr.length() == 1) greenStr = "0" + greenStr; blueStr = Integer.toHexString(this.blue); if (blueStr.length() == 1) blueStr = "0" + blueStr; return "#" + redStr + greenStr + blueStr; }

public Color139 add(Color139 other) { Color139 newcolor; // new color object that is dimmer than this color int newRed; // new red color value int newGreen; // new green color value int newBlue; // new blue color value

newRed = this.red + other.red; newGreen = this.green + other.green; newBlue = this.blue + other.blue; newcolor = new Color139 (newRed, newGreen, newBlue); return newcolor; }

public Color139 sub(Color139 other) { // MAKE ME return Color139.BLACK; }

public Color139 dim() { Color139 newcolor; // new color object that is dimmer than this color int newRed; // new red color value int newGreen; // new green color value int newBlue; // new blue color value

newRed = (int) (this.red / 1.2); newGreen = (int) (this.green / 1.2); newBlue = (int) (this.blue / 1.2); newcolor = new Color139 (newRed, newGreen, newBlue);

return newcolor; }

public Color139 darken() { // MAKE ME return Color139.BLACK; }

public boolean equals(Color139 other) { // MAKE ME return false; }

public Color139 lighten() { // MAKE ME return Color139.BLACK; }

public Color139 brighten() { // MAKE ME return Color139.BLACK; } }

Need to generate the output as seen in picture

(using command prompt, each of these files stay separate just need to fill in constructors for the fileimage text in transcribed) i.e java Main > output.html

color BLACK color RED color GREEN color YELLOW color BLUE color MAGENTA color CYAN color WHITE is #eeeeee in hex and looks like this: is #ffeeee in hex and looks like this: is #eeffee in hex and looks like this: is #ffffee in hex and looks like this: is #eeeeff in hex and looks like this: IS #ffeeff in hex and looks like this: is #eeffff in hex and looks like this: s #ffffff in hex and looks like this: color RED+GREEN color RED+YELLOW color WHITE-CYAN is #ffffee in hex and looks like this: is #ffffee in hex and looks like this: is #ffeeee in hex and looks like this: color cc1(34,54,189) color cc21128,32,64) s #2236bd in hex and looks like this: is #802040 in hex and looks like this: color dark BLUE color dim BLUE is #eeeedf in hex and looks like this: is #eeeed4 in hex and looks like this: Does BLUE GREENCYAN? true color cc41e,64,e color lighten*e (0, 64,0 color lighten1 e,64,0h color lighten*2 e,64,e) color lighten*3 (0,64,0 color lighten*4 (0, 64,0 color lighten*5 e,64,e) color lighten*6 e,64,e color lighten*7 {0,64,0} is #004000 in hex and looks like this: is #206820 in hex and looks like this: is #408040 in hex and looks like this: is #68a068 in hex and looks like this: is #80c980 in hex and looks like this: is #a0e@a@ 1n hex and looks like this: is #ceffce in hex and looks like this: is #e@ffee in hex and looks like this: s #ffffff in hex and looks like this: color cc510,64,e) color brighten*e e,64,0) color brighten*1 e,64,e is #0040ee in hex and looks like this: is #ee4cee in hex and looks like this: is #ee5bee in hex and looks like this

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Accidental Data Scientist

Authors: Amy Affelt

1st Edition

1573877077, 9781573877077

More Books

Students also viewed these Databases questions

Question

What are the determinants of cash cycle ? Explain

Answered: 1 week ago