package questions; import java.util.Collection; import java.util.List; import course.Test; /** * An abstract representation of * a bank of questions stored for the user. * It has a list of questions in it. */ public abstract class QuestionBank { Collection questions; public QuestionBank() { } /** 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. // (!questions.contains(q)) && // The question is not empty. (q.getText() != null) && (q.getText().length() > 0) && // The answer is not empty. (q.getAnswer() != null) && (q.getAnswer().length() > 0) && // The time and difficulty are not empty. (q.getTime() != 0) && (q.getDifficulty() != 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. // (questions'.contains(q)) */ public abstract void addQuestion(Question q); /** Edits a question in the question bank. @param question The question to be edited. pre: // The given question is in this.questions. // questions.contains(q); */ public abstract void editQuestion(Question q); /** 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(q); 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. // The questions database size must be one smaller than before (!questions'.contains(q)) && (questions'.size() == questions.size()-1); */ public abstract void removeQuestion(Question q); public abstract List getQuestions(); /** Finds question(s) in the question bank. @param question The target question to search for in the bank. post: // The questions in the return list must match the query // forall(Question q ; return.contains(q); q.questionText.contains(query) || q.answer.toString().contains(query)); */ public abstract List search(String query); }