package questions; import java.util.Collection; import tests.Test; /** * A Question Bank stores all questions that have been created and includes * functionalites to add, remove, find, or sort questions. */ public abstract class QuestionBank { int numQuestions; Collection questions; /** * Adds a new question into the question bank. * @param question The question to be added to the question bank. pre: // There is no record in the Collection that is exactly the same as // the question to be added. // !exists (Question quest ; questions.contains(quest) ; quest.questionText.equals(question.questionText) && quest.answer.equals(question.answer)) && // The question is not empty. (question.question != null) && (question.questionText.length() > 0) && // The answer is not empty. (question.answer != null) && (question.answer.length() > 0) && // The time and difficulty are not empty. (question.time != 0) && (question.difficulty != 0) post: // A record is in the output data if and only if it is the // new record to be added or if it is in the input data. // forall (Questions quest ; questions'.contains(quest) iff quest.questionText.equals(question.questionText) && quest.answer.equals(question.answer) || questions.contains(quest)); */ abstract void addQuestion(Question question); /** * Deletes a question from the question bank. * @param question The question to be removed from the question bank. pre: // The given question is in this.questions. // questions.contains(question); post: // A record is in the output data if and only if it is not the // existing record to be deleted and it is in the input data. // forall (Questions quest ; questions'.contains(quest) iff !quest.questionText.equals(question.questionText) && !quest.answer.equals(question.answer) && questions.contains(quest)); */ abstract void deleteQuestion(Question question); /** * Finds a question in the question bank. * @param question The target question to search for in the bank. post: // If the target question exists in the question bank, then the output // is equal to that question, otherwise output is null. // exists (Question quest ; questions.contain(quest) ; quest.questionText.equals(question.questionText) && quest.answer.equals(question.answer) && quest.equals(return)) || !exists (Question quest ; questions.contain(quest) ; quest.questionText.equals(question.questionText) && quest.answer.equals(question.answer)) && return == null; */ abstract void findQuestion(Question question); /** * Sorts all questions on a user-selected condition. */ abstract void sortQuestions(); }