<?

/* Question
 * 
 * This abstract class contains the information for each question on the
 * ballot.  Classes that extend this class will represent different types of
 * questions (choose X of Y, rank, openended)
 */

abstract class Question
{
	/* Member fields
	 * 
	 * String $text - the text of the question
	 * String $more_info_link - the link for more information for the question
	 *   (might be "")
	 * Array $choices - an array of Candidates which are the choices for the
	 *   current question
	 * int $total_choices - the total number of candidates added to the
	 *   Question so far.
	 * int $question_number - the position of this question in the ballot
	 */
	protected $text;
	protected $more_info_link;
	protected $choices;
	protected $total_choices = 0;
	protected $question_number;

	/* __construct($question_text, $info_link)
	 *
	 * The constructor takes in basic information about the class, and
	 * initializes the choices array to a new array
	 *
	 * In: String $question_text - the text of the question
	 * In: String $info_link - the filename/link to more information about the
	 *     question
	 * In: int $number - the number that this question is in the ballot (1 =
	 *     first, 2 = second etc...) 
	 */
	public function __construct($question_text, $info_link, $number){
		$this->choices = array();
		$this->more_info_link = $info_link;
		$this->text = $question_text;
		$this->question_number = $number;
	}
	
	/* getText()
	 *
	 * This method returns the text of the question
	 *
	 * Return: String - the text of the question
	 */
	public function getText(){
		return $this->text;
	}

	/* getMoreInfoLink()
	 *
	 * This method returns the link/filename for more information about the
	 * question
	 *
	 * Return: String - the link/filename for more information about the
	 *   question
	 */
	public function getMoreInfoLink(){
		return $this->more_info_link;
	}

	/* getCandidate()
	 *
	 * This method returns the nth candidate for the questions, where n is the
	 * argument to the method.
	 *
	 * In: int $candidate_number - the number of the candidate to get
	 * Return: Candidate - the nth Candidate for the question
	 */
	public function getCandidate($candidate_number){
		return $this->choices[$candidate_number];
	}

	/* getNumberCandidates()
	 *
	 * This method returns the number of candidates for the question
	 *
	 * Return: int - the number of candidates for the question
	 */
	public function getNumberCandidates(){
		return $this->total_choices;
	}
	
	/* getQuestionNumber()
	 *
	 * This method returns the question number of this question
	 *
	 * Return: int - the question number of this question in the ballot
	 */
	public function getQuestionNumber(){
		return $this->question_number;
	}

	/* addCandidate(Candidate $candidate)
	 *
	 * This method adds a candidate to the array of candidates in this
	 * question.
	 *
	 * In: Candidate $candidate - the candidate to add
	 */
	public function addCandidate(Candidate $candidate){
		$this->choices[$this->total_choices] = $candidate;
		$this->total_choices++;
	}

	/* generateHTML()
	 * 
	 * This method generates the HTML for the given question.
	 *
	 * Return: String - the HTML for the question
	 */
	abstract public function generateHTML();
	
	/* verifyQuestion($answers)
	 * 
	 * This method verifies that the answers submitted for the question are
	 * valid (ranking questions only have the appropriate numbers submitted,
	 * choose X of Y has at most X choices checked etc...)
	 * 
	 * In: Array $answers - the array of answers provided by the user for the
	 *     question.  
	 * Return: boolean - true if the answers and valid and false otherwise
	 */
	abstract public function verifyQuestion($answers);
	
	/* getNumberAnswers()
	 *
	 * This method returns the number of possible answers for the question (for
	 * example, calling this method from a question where you choose 3 of 6
	 * possible choices would result in the number 3 being returned)
	 *
	 * Return: int - the number of choices a voter is allowed to make for this
	 *   question
	 */
	abstract public function getNumberAnswers();

}

?>
