forked from nus-cs2103-AY1819S1/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Model.java
208 lines (167 loc) · 5.9 KB
/
Model.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
package seedu.address.model;
import java.util.List;
import java.util.function.Predicate;
import javafx.collections.ObservableList;
import seedu.address.commons.core.index.Index;
import seedu.address.commons.events.model.TabChangeEvent;
import seedu.address.commons.events.ui.SetUpDisplayCardInfoEvent;
import seedu.address.model.card.Card;
import seedu.address.model.card.UniqueCardList;
import seedu.address.model.person.Person;
import seedu.address.model.state.State;
import seedu.address.model.test.Attempt;
import seedu.address.model.test.TriviaResult;
import seedu.address.model.test.TriviaTest;
/**
* The API of the Model component.
*/
public interface Model {
/** {@code Predicate} that always evaluate to true */
Predicate<Person> PREDICATE_SHOW_ALL_PERSONS = unused -> true;
/** {@code Predicate} that always evaluate to true */
Predicate<Card> PREDICATE_SHOW_ALL_CARDS = unused -> true;
Predicate<Card> PREDICATE_SHOW_RECENTLY_IMPORTED_CARDS = c -> c.isRecentlyAdded();
/** Clears existing backing model and replaces with the provided new data. */
void resetData(ReadOnlyAddressBook newData);
/** Clears existing backing model and replaces with the provided new data. */
void resetData(ReadOnlyTriviaBundle newData);
/** Returns the AddressBook */
ReadOnlyAddressBook getAddressBook();
/**
* Returns true if a person with the same identity as {@code person} exists in the address book.
*/
boolean hasPerson(Person person);
/**
* Deletes the given person.
* The person must exist in the address book.
*/
void deletePerson(Person target);
/**
* Adds the given person.
* {@code person} must not already exist in the address book.
*/
void addPerson(Person person);
/** Returns an unmodifiable view of the filtered person list */
ObservableList<Person> getFilteredPersonList();
/**
* Updates the filter of the filtered person list to filter by the given {@code predicate}.
* @throws NullPointerException if {@code predicate} is null.
*/
void updateFilteredPersonList(Predicate<Person> predicate);
/**
* Returns true if the model has previous address book states to restore.
*/
void commitAddressBook();
/** Returns the TriviaBundle */
ReadOnlyTriviaBundle getTriviaBundle();
/**
* Returns true if a card with the same identity as {@code card} exists in the list of trivia bundle.
*/
boolean hasCard(Card card);
/**
* Returns true if any cards with the same identity as {@code card} exists in the list of trivia bundle.
*/
boolean haveAnyCard(UniqueCardList cards);
/**
* Adds the given card.
* {@code card} must not already exist in the list of trivia bundle.
*/
void addCard(Card card);
/**
* Adds a list of given cards.
* {@code cards} must not already exist in the list of trivia bundle.
* @param cards
*/
void addMultipleCards(UniqueCardList cards);
/**
* Deletes the given card.
* The card must exist in the trivia bundle.
*/
void deleteCard(Card target);
/** Returns an unmodifiable view of the filtered card's list */
ObservableList<Card> getFilteredCardList();
/**
* Return true if the card list is not empty
*/
boolean canClearCardList();
/**
* Updates the filter of the filtered card list to filter by the given {@code predicate}.
* @throws NullPointerException if {@code predicate} is null.
*/
void updateFilteredCardList(Predicate<Card> predicate);
/**
* Replaces the given card {@code target} with {@code editedCard}.
* {@code target} must exist in the address book.
* The person identity of {@code editedPerson} must not be the same as another existing person in the address book.
*/
void updateCard(Card target, Card editedCard);
/**
* Saves the current trivia bundle state for undo/redo.
*/
void commitTriviaBundle();
/**
* Returns true if the model has previous trivia bundle states to restore.
*/
boolean canUndoTriviaBundle();
/**
* Returns true if the model has undone trivial bundle states to restore.
*/
boolean canRedoTriviaBundle();
/**
* Restores the model's trivial bundle to its previous state.
*/
void undoTriviaBundle();
/**
* Restores the model's trivial bundle to its previously undone state.
*/
void redoTriviaBundle();
/**
* Set a test to the trivia application model.
*/
void startTriviaTest(TriviaTest test);
/**
* Stop a test in the trivia application model.
*/
void stopTriviaTest();
/**
* Match a question to another answer. To be used in a Match Test.
*/
boolean matchQuestionAndAnswer(Index questionIndex, Index answerIndex);
/**
* Obtain the trivia test that is running.
*/
TriviaTest getCurrentRunningTest();
/**
* Get the app state that the application is currently in.
*/
State getAppState();
/**
* Set the AppState of the model according to the given State
*/
void setAppState(State state);
/**
* Return boolean on whether the model in in a testing state.
*/
boolean isInTestingState();
/**
* Returns boolean on whether the open ended test answer is correct
*/
boolean isOpenEndedTestAnswerCorrect(char in);
/**
* Records user answer
*/
void recordAnswerToOpenEndedTest(String userInput);
/**
* Returns the result list for trivia test.
*/
List<TriviaResult> getTriviaResultList();
/**
* Return the Attempts in trivia test made by the given card.
*/
List<Attempt> getAttemptsByCard(Card card);
/**
* Used to provide the necessary information to display card info.
*/
void handleSetUpDisplayCardInfoEvent(SetUpDisplayCardInfoEvent event);
void handleChangeTab(TabChangeEvent event);
}