public class Video {
    final int MIN_TITLE_LENGTH = 2;
    final int MAX_TITLE_LENGTH = 250;
    final int MIN_LENGTH      = 15;
    final int MAX_LENGTH      = 1000;
    final String [] FORMATS   = {"DVD", "Blu-ray"};

    private int collection_no;
    private String title;
    private int length;
    private String format;

    public Video(int collection_no, String title, int length, String format)
        throws IllegalArgumentException {
        if (title_good(title) && length_good(length) && format_good(format)){
            this.collection_no = collection_no;
            this.title = title;
            this.length = length;
            this.format = format;
        }
    }

    public String toString(){
        return "#" + collection_no + ": " + title + ", " + length 
            + " minutes, " + format;
    }

    public int collection_no(){
        return collection_no;
    }

    public String title(){
        return title;
    }

    public int length(){
        return length;
    }

    public String format(){
        return format;
    }

    private boolean title_good(String title) throws IllegalArgumentException {
        if (title.length() < MIN_TITLE_LENGTH || title.length() > MAX_TITLE_LENGTH){
            throw new IllegalArgumentException("Title must be between " +
                MIN_TITLE_LENGTH + " and " + MAX_TITLE_LENGTH + " characters long");
        } else {
            return true;
        }
    }

    private boolean length_good(int length) throws IllegalArgumentException {
        if (length < MIN_LENGTH || length > MAX_LENGTH){
            throw new IllegalArgumentException("Length must be between " +
                MIN_LENGTH + " and " + MAX_LENGTH + " characters long");
        } else {
            return true;
        }
    }

    private boolean format_good(String format) throws IllegalArgumentException {
        if (format.length() == 0) {
            throw new IllegalArgumentException("You must specify a format");
        } else {
            for (int i = 0; i < FORMATS.length; i++){
                if (format.equals(FORMATS[i])) {
                    return true;
                }
            }
            throw new IllegalArgumentException( format + " is not a valid format");
        }
    }
}
