A4Methods (7)_Solutions - import java.awt.*; /* Contains...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.awt.*; /** Contains static methods of assignment A4 */ public class A4Methods { /** = the complement of color rgb. */ public static Color complementRGB(Color rgb) { return new Color(255-rgb.getRed(), 255-rgb.getGreen(), 255-rgb.getBlue()); } /** = s truncated (if necessary) to its first 5 characters. */ public static String truncateTo5(String s) { if (s.length()>5) return s.substring(0,5); return s; } /** = RGB value rgb in the form "[R, G, B]". Precondition: each of the rgb values is an integer in the range 0. .255. */ public static String toString(Color rgb) { return "["+rgb.getRed()+", "+rgb.getGreen()+", "+rgb.getBlue()+"]"; } /** = CMYK value cmyk in the form "[C, M, Y, K]". In the output, each of C, M, Y, and K should take at most 5 characters. Precondition: All parameters are 0 and 1. */ public static String toString(CMYK cmyk) { return "["+cmyk.getCyan()+", "+cmyk.getMagenta()+", "+cmyk.getYellow() +" ,"+cmyk.getBlack()+"]"; } /** = HSV value rgb in the form "[H, S, V]". In the output,
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

A4Methods (7)_Solutions - import java.awt.*; /* Contains...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online