package worms.util;

import be.kuleuven.cs.som.annotate.*;

/**
 * A class for signalling illegal names for worms
 *
 *  Each illegal name exception involves the name and the index of the character where the error occurred.
 *
 *  @version 1.0
 *  @author Arthur Bols / Leen Dereu
 */
public class IllegalNameException extends RuntimeException {

    /**
     * Variable registering the index of this illegal name exception
     */
    private final int index;

    /**
     * Variable referencing the naem of this illegal name exception
     */
    private final String name;

    /**
     * Initalize this new illegal name exception with given operands
     *
     * @param   index
     *          The index of the character where the exception occurred.
     * @param   name
     *          The String where the error occurred.
     *
     * @post    The index of this new illegal name exception is set to the given index
     *          | new.getIndex() == index
     *
     * @post    The name of this new illegal name exception is set to the given name
     *          | new.getName() == name
     */
    public IllegalNameException(int index, String name) {
        this.index = index;
        this.name = name;
    }

    /**
     * Return the index of this illegal name exception.
     *
     * @return this.index
     */
    @Basic @Immutable
    public int getIndex() {
        return this.index;
    }

    /**
     * Return the name of this illegal name exception.
     *
     * @return this.name
     */
    @Basic @Immutable
    public String getName() {
        return this.name;
    }
}
