CMYK_Solutions

CMYK_Solutions - if(s.length<= 5 return s return...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 /** An instance represents a CMYK value */ public class CMYK { public double c public double m public double y public double k /** Constructor: the CMYK value (c, m, y, k). Precondition: All components c, m, y, and k are public CMYK(double c, double m, double y, double k) { this.c= c this.m= m this.y= y this.k= k } /** = String s truncated (if necessary) to its first 5 characters. */ public static String truncate(String s) {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if (s.length() <= 5) return s return s.substring(0,5) } /** = string representation of this instance */ public String toString() { return "(" + truncate("" + c) + ", " + truncate("" + m) + ", " + truncate("" + y) + ", " + truncate("" + k) + ")" } } /** Color cyan. 0 h c h 1. */ /** Color magenta. 0 h m h 1. */ /** Color yellow. 0 h y h 1. */ /** Color black. 0 h c h 1. */ & 0 and h 1.*/...
View Full Document

Ask a homework question - tutors are online