package colors;

public class Color {

    private int red, green, blue;

    private String name;

    public Color(int red, int green, int blue, String name) {

        assert(red < 256 && red >= 0);

        assert(green < 256 && green >= 0);

        assert(blue < 256 && blue >= 0);

        this.red = red;

        this.green = green;

        this.blue = blue;

        this.name = name;

    }

    String getName() {

        return name;

    }

    public String getHexValue() {

        return "#"+getHexValue(red)+getHexValue(green)+

             getHexValue(blue).toUpperCase();

    }

    private String getHexValue(int intValue) {

        String s = Integer.toHexString(intValue);

        if (s.length() == 1) {

            return "0"+s;

        } else {

            return s;

        }

    }

}