Skip to content

Commit 4fc9299

Browse files
Merge pull request #89 from CSC207-2022F-UofT/Anthony's_Branch
Anthony's branch
2 parents 838fcd6 + 6b375c0 commit 4fc9299

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+549
-299
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ repositories {
77
}
88

99
dependencies {
10-
implementation 'junit:junit:4.13.1'
11-
testImplementation('org.junit.jupiter:junit-jupiter:5.6.0')
10+
implementation 'junit:junit:4.13.2'
11+
testImplementation('org.junit.jupiter:junit-jupiter:5.9.0')
1212
implementation 'com.formdev:flatlaf:2.6'
1313
}
1414

src/main/java/create_flashcard_use_case/FcCMain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import create_flashcard_use_case.fcCScreens.FcCResponsePresenter;
55
import create_flashcard_use_case.fcCScreens.FcCScreen;
66
import data_access.*;
7-
import view.Screen;
7+
import frameworks_and_drivers.Screen;
88

99
import javax.swing.*;
1010
import java.io.IOException;

src/main/java/delete_flashcard_use_case/FcRMain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import data_access.*;
44
import delete_flashcard_use_case.FcRScreens.FcRController;
55
import delete_flashcard_use_case.FcRScreens.FcRResponsePresenter;
6-
import view.Screen;
6+
import frameworks_and_drivers.Screen;
77

88
import javax.swing.*;
99
import java.io.IOException;

src/main/java/edit_flashcard_set_use_case/FCSetEditorMain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import edit_flashcard_set_use_case.screens.FCSetEditorScreen;
66
import data_access.DBGateway;
77
import data_access.entity_request_models.FlashcardSetDsRequestModel;
8-
import view.Screen;
8+
import frameworks_and_drivers.Screen;
99

1010
public class FCSetEditorMain extends Screen {
1111
/**

src/main/java/edit_flashcard_use_case/FlashcardEditorMain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import edit_flashcard_use_case.screens.FlashcardEditorScreen;
66
import data_access.*;
77
import data_access.entity_request_models.FlashcardDsRequestModel;
8-
import view.Screen;
8+
import frameworks_and_drivers.Screen;
99

1010
public class FlashcardEditorMain extends Screen {
1111
/**

src/main/java/editor_main_page/EditorMainPage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import data_access.*;
44
import data_access.entity_request_models.FlashcardDsRequestModel;
55
import data_access.entity_request_models.FlashcardSetDsRequestModel;
6-
import view.Screen;
6+
import frameworks_and_drivers.Screen;
77

88
import javax.swing.*;
99
import java.io.IOException;

src/main/java/entities/MultipleChoiceQuestion.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,22 @@
1010
* @author Anthony
1111
*/
1212
public class MultipleChoiceQuestion extends QuizQuestion {
13+
/* If given term is true, then the term is the initial prompt.
14+
If given term is false, then the definition is the initial prompt.
15+
*/
1316
private final boolean givenTerm;
1417

1518
private String question;
16-
private String[] choices;
19+
private final String[] choices;
1720
private final int numChoices = 4;
1821

1922
private static final Random rand = new Random();
2023

24+
/**
25+
* Constructs a multiple choice question.
26+
* @param flashcards the list of flashcards
27+
* @param index the index of a specific flashcard
28+
*/
2129
public MultipleChoiceQuestion(List<Flashcard> flashcards, int index) {
2230
this.givenTerm = rand.nextBoolean();
2331
this.choices = new String[numChoices];
@@ -54,6 +62,10 @@ public void generateQuestion(List<Flashcard> flashcards, int index) {
5462
}
5563
}
5664

65+
/**
66+
* Returns the string representation of the multiple choice question.
67+
* @return string representation
68+
*/
5769
@Override
5870
public String toString() {
5971
StringBuilder s = new StringBuilder("Prompt: " + this.question + "\n");
@@ -63,15 +75,26 @@ public String toString() {
6375
return s.toString();
6476
}
6577

66-
/** GETTERS AND SETTERS **/
78+
/**
79+
* Gets the question.
80+
* @return the question
81+
*/
6782
public String getQuestion() {
6883
return question;
6984
}
7085

86+
/**
87+
* Sets the question.
88+
* @param question the question
89+
*/
7190
public void setQuestion(String question) {
7291
this.question = question;
7392
}
7493

94+
/**
95+
* Sets the choices.
96+
* @return the choices
97+
*/
7598
public String[] getChoices() {
7699
return choices;
77100
}

src/main/java/entities/Quiz.java

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class Quiz {
1616

1717
private int score;
1818

19-
private static final Random rand = new Random();
19+
private static final Random rand = new Random(); // used for calculating random numbers
2020

2121
/**
2222
* Precondition: flashcards contains at least 4 flashcards, and at least 1 question type is enabled in quizSettings.
@@ -37,7 +37,7 @@ public Quiz(QuizSettings quizSettings, List<Flashcard> flashcards) {
3737
public void generateQuestions() {
3838
int numQuestions = this.quizSettings.getNumQuestions();
3939

40-
ArrayList<String> types = new ArrayList<String>();
40+
List<String> types = new ArrayList<>();
4141
if (this.quizSettings.isTrueFalseOn()) {
4242
types.add("TF");
4343
}
@@ -72,39 +72,50 @@ public void evaluate() {
7272
}
7373
}
7474

75-
/** GETTERS AND SETTERS **/
76-
public ArrayList<String> getUserAnswers() {
77-
ArrayList<String> userAnswers = new ArrayList<>();
78-
for (QuizQuestion q : this.quizQuestions) {
79-
userAnswers.add(q.getUserAnswer());
80-
}
81-
return userAnswers;
82-
}
83-
84-
public void setUserAnswers(ArrayList<String> userAnswers) {
75+
/**
76+
* Sets the user answers.
77+
* @param userAnswers the user answers
78+
*/
79+
public void setUserAnswers(List<String> userAnswers) {
8580
for (int i = 0; i < userAnswers.size(); i++) {
8681
QuizQuestion q = this.quizQuestions.get(i);
8782
String a = userAnswers.get(i);
8883
q.setUserAnswer(a);
8984
}
9085
}
9186

92-
public ArrayList<String> getActualAnswers() {
93-
ArrayList<String> actualAnswers = new ArrayList<>();
87+
/**
88+
* Gets the actual answers.
89+
* @return the actual answers
90+
*/
91+
public List<String> getActualAnswers() {
92+
List<String> actualAnswers = new ArrayList<>();
9493
for (QuizQuestion q : this.quizQuestions) {
9594
actualAnswers.add(q.getActualAnswer());
9695
}
9796
return actualAnswers;
9897
}
9998

99+
/**
100+
* Gets the quiz questions.
101+
* @return the quiz questions
102+
*/
100103
public List<QuizQuestion> getQuizQuestions() {
101104
return this.quizQuestions;
102105
}
103106

107+
/**
108+
* Gets the quiz score.
109+
* @return the score
110+
*/
104111
public int getScore() {
105112
return this.score;
106113
}
107114

115+
/**
116+
* Gets the number of questions.
117+
* @return the number of questions
118+
*/
108119
public int getNumQuestions() {
109120
return this.quizQuestions.size();
110121
}

src/main/java/entities/QuizQuestion.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,22 @@ public boolean isCorrect(){
2727
return this.actualAnswer.equalsIgnoreCase(this.userAnswer);
2828
}
2929

30-
/** GETTERS AND SETTERS **/
30+
/**
31+
* Gets the actual answer.
32+
* @return the actual answer
33+
*/
3134
public String getActualAnswer() {
3235
return actualAnswer;
3336
}
3437

38+
/**
39+
* Sets the actual answer.
40+
* @param actualAnswer the actual answer
41+
*/
3542
public void setActualAnswer(String actualAnswer) {
3643
this.actualAnswer = actualAnswer;
3744
}
3845

39-
public String getUserAnswer() {
40-
return userAnswer;
41-
}
42-
4346
/**
4447
* Sets the user answer. If the user answer is null or empty, the user answer should be set to null.
4548
* @param userAnswer the user answer

0 commit comments

Comments
 (0)