/home/caleb/ASDV-Java/Semester 2/Assignments/lab2_CalebFontenot/src/main/java/com/calebfontenot/lab5_calebfontenot/TrueFalseQuiz.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package com.calebfontenot.lab5_calebfontenot;
import java.util.Date;
@author
public class TrueFalseQuiz {
int currentQuestion;
TrueFalseQuestion[] trueFalseQuestions;
public TrueFalseQuiz()
{
trueFalseQuestions = new TrueFalseQuestion[5];
trueFalseQuestions[0]
= new TrueFalseQuestion("The Pacific Ocean is larger than the Atlantic Ocean.",
true, new Date());
trueFalseQuestions[1]
= new TrueFalseQuestion("The Suez Canal connects the Red Sea and the Indian Ocean.", false, new Date());
trueFalseQuestions[2]
= new TrueFalseQuestion("The source of the nile River is in Egypt.", false, new Date());
trueFalseQuestions[3]
= new TrueFalseQuestion("Lake Baikal is the world\'s oldest and deepest freshwater lake.", true, new Date());
trueFalseQuestions[4]
= new TrueFalseQuestion("The Amazon River is the longest river in the Americas.", true, new Date());
this.currentQuestion = 0;
}
public TrueFalseQuiz(String[] questions, boolean[] trueFalse)
{
trueFalseQuestions = new TrueFalseQuestion[questions.length];
for (int i = 0, j = 0; i < questions.length; ++i, ++j) {
trueFalseQuestions[i] = new TrueFalseQuestion(
questions[i],
trueFalse[j],
new Date());
this.currentQuestion = 0;
}
}
@return
public String nextQuestion()
{
if (++this.currentQuestion == this.trueFalseQuestions.length) {
this.currentQuestion = 0;
}
this.trueFalseQuestions[this.currentQuestion].setWhenLastUsed(new Date());
return this.trueFalseQuestions[this.currentQuestion].getQuestion();
}
@return
public boolean isTrue() {
return this.trueFalseQuestions[this.currentQuestion].isIsTrue();
}
public int getCurrentQuestion()
{
return currentQuestion;
}
public void setCurrentQuestion(int currentQuestion)
{
this.currentQuestion = currentQuestion;
}
public TrueFalseQuestion[] getTrueFalseQuestions()
{
return trueFalseQuestions;
}
public void setTrueFalseQuestions(TrueFalseQuestion[] trueFalseQuestions)
{
this.trueFalseQuestions = trueFalseQuestions;
}
}