package testtool.teacher_app.test_view; /** * This class contains the structure for storing and filtering saved tests. * It contains a list of tests in the TestBank, and a list of tests that * can be currently viewed after being filtered. */ import java.util.Calendar; import java.util.List; import testtool.component.Course; import testtool.component.Test; public abstract class TestBank { private List tests; private List shownTests; /** *add will add a test to the TestBank. */ /*@ requires //test to be a test, and not already exist in the list !(tests.contains(test)); ensures //test is added to the list tests.contains(test); @*/ public abstract void add(Test test); /** *delete will remove the test from the list at the given index */ /*@ requires (* tests.size() > index *); ensures (* !tests.contains(\old tests.get(index)) *); @*/ public abstract void delete(int index); /** *edit will allow the user to edit a test's data that is already in the list */ /*@ requires //test is in the list (tests.contains(test)); ensures (* the test is now able to be edited *); @*/ public abstract void edit(Test test); /** *sort will sort the list of tests in ascending order based on the flag *given */ /*@ requires (* flag is a legitimate SortFlag *); ensures (* the test list is now sorted by that flag in ascending order. *); @*/ public abstract void sort(SortFlag flag); /** *filter will modify the shown tests list to only include tests that the *given filter allows */ /*@ requires (* filter is an actual filter. *); ensures (* shown tests gets updated to only include tests that the filter allows *); @*/ public abstract void filter(TestFilter filter); /** *This class contains all of the different filtering options you can filter *tests by. Values filled in here that get passed to the filter method *will ensure only tests with those values get put into the shown tests *list */ private abstract class TestFilter { private List authors; private List courses; private List keywords; private int minPoint; private int maxPoint; private int minTime; private int maxTime; private int minDifficulty; private int maxDifficulty; private Calendar lastUsed; } /** *This enum contains all the different ways a test can be sorted. */ private enum SortFlag { AUTHOR, COURSE, CREATED, POINTS, DIFFICULTY, LAST_USED, TIME, QUESTION_COUNT } }