package net.sourceforge.jsurveyor;

/**
 * Class to model multiplechoice answers. 
 * Saves the choice a user selects.
 * @version 1.0
 * @author Claus Methmann Christensen
 * @author Anders Spliid Hansen
 * @author Esben Iversen Hansen
 * @author Lars H Jensen
 * @author Marcus Overheu
 * @author Thomas Ramdal
 * @author Peter Thomsen
 */
public class AnswerMultipleChoice extends Answer {

	/**
	 * Field choice
	 */
	private int choice;
	
	/**
	 * Constructor for AnswerMultipleChoice
	 */
	public AnswerMultipleChoice() {
		super();
	}
	
	/**
	 * Constructor for AnswerMultipleChoice
	 * @param questionID int
	 */
	public AnswerMultipleChoice(int questionID) {
		super(questionID);
	}
	
	/**
	 * Constructor for AnswerMultipleChoice
	 * @param questionID int
	 * @param choice int
	 */
	public AnswerMultipleChoice(int questionID, int choice) {
		super(questionID);
		this.choice = choice;
	}
	
	/**
	 * Constructor for AnswerMultipleChoice, use through DataAccess.
	 * @param answerID int
	 * @param questionID int
	 * @param choice int
	 */
	public AnswerMultipleChoice(int answerID, int questionID, int choice) {
		super(answerID, questionID);
		this.choice = choice;
	}
	
	/**
	 * Returns the index number of the answered choice.
	 * @return int
	 */
	public int getChoice() {
		return choice;
	}
	
	/**
	 * Sets the index number for the selected choice.
	 * @pre the choice must be present in the question that this is an answer for.
	 * @param choice int
	 */
	public void setChoice(int choice) {
		this.choice = choice;
	}
	
	/**
	 * Returns the answerID prefixed with a M to represent it is a multiplechoice.
	 * @return String
	 */
	public String toString() {
		return "M" + getAnswerID();	
	}
}
