Skip to content

Commit 8e42245

Browse files
authored
Merge pull request #71 from CSC207-2022F-UofT/main
Undate
2 parents 00017bb + e6d58fb commit 8e42245

29 files changed

+614
-111
lines changed

src/main/java/flashcardCreator/FcCController.java

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/main/java/flashcardCreator/FcCFailure.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/main/java/flashcardCreator/FcCInputBoundary.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package flashcardCreator;
22

3+
/**
4+
* Input boundary for flashcard creator.
5+
* Application business rules.
6+
* @author Junyu Chen
7+
*/
8+
39
public interface FcCInputBoundary {
410
FcCResponseModel create(FcCRequestModel requestModel);
511

src/main/java/flashcardCreator/FcCInterator.java renamed to src/main/java/flashcardCreator/FcCInteractor.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,32 @@
66
import entityRequestModels.FlashcardDsRequestModel;
77

88
import java.time.LocalDateTime;
9-
10-
public class FcCInterator implements FcCInputBoundary{
11-
FcCPresenter presenter;
9+
/**
10+
* Interactor for flashcard creator.
11+
* Application business rules.
12+
* @author Junyu Chen
13+
*/
14+
public class FcCInteractor implements FcCInputBoundary{
15+
FcCOutputBoundary presenter;
1216
IFlashcardDataAccess fcDataAccess;
1317
IFlashcardSetDataAccess fcsDataAccess;
1418

15-
public FcCInterator(DBGateway gateway, FcCPresenter presenter){
19+
/**
20+
* Create FcCInteractor
21+
* @param gateway Database gateway.
22+
* @param presenter Presenter for failure or success view.
23+
*/
24+
public FcCInteractor(DBGateway gateway, FcCOutputBoundary presenter){
1625
this.presenter = presenter;
1726
this.fcDataAccess = gateway.getFlashcardGateway();
1827
this.fcsDataAccess = gateway.getFlashcardSetGateway();
1928
}
29+
30+
/**
31+
* Create flashcard with given term, definition in the given flashcard set recording the date of creation.
32+
* If term or definition is empty flashcard set does not exist, returns the corresponding error.
33+
* @return Success or failure view.
34+
*/
2035
@Override
2136
public FcCResponseModel create(FcCRequestModel requestModel) {
2237
if(requestModel.getDefinition().isEmpty()||requestModel.getTerm().isEmpty()){

src/main/java/flashcardCreator/FcCMain.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
package flashcardCreator;
22

3+
import flashcardCreator.fcCScreens.FcCController;
4+
import flashcardCreator.fcCScreens.FcCResponsePresenter;
35
import flashcardCreator.fcCScreens.FcCScreen;
46
import dataAccess.*;
5-
67
import javax.swing.*;
78
import java.io.IOException;
89

10+
/**
11+
* Main frame for flashcard Creator.
12+
* @author Junyu Chen
13+
*/
914
public class FcCMain extends JFrame {
15+
/**
16+
* Create main frame for the flashcard creator.
17+
* @param flashcardSetId id of the flashcard set which flashcard will be stored in.
18+
*/
1019
public FcCMain(int flashcardSetId){
1120
DBGateway gateway;
1221
try{
@@ -17,8 +26,8 @@ public FcCMain(int flashcardSetId){
1726
catch (IOException e){
1827
throw new RuntimeException("Could not access files.");
1928
}
20-
FcCPresenter presenter = new FcCResponseFormatter();
21-
FcCInputBoundary interactor = new FcCInterator(gateway,presenter);
29+
FcCOutputBoundary presenter = new FcCResponsePresenter();
30+
FcCInputBoundary interactor = new FcCInteractor(gateway,presenter);
2231
FcCController controller = new FcCController(interactor, flashcardSetId);
2332
FcCScreen fcCScreen= new FcCScreen(controller, this);
2433
this.add(fcCScreen);

src/main/java/flashcardCreator/FcCPresenter.java renamed to src/main/java/flashcardCreator/FcCOutputBoundary.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package flashcardCreator;
2-
3-
public interface FcCPresenter {
2+
/**
3+
* Presenter for flashcard creator.
4+
* Application business rules.
5+
* @author Junyu Chen
6+
*/
7+
public interface FcCOutputBoundary {
48
FcCResponseModel prepareSuccessView(FcCResponseModel responseModel);
59

610
FcCResponseModel prepareFailView(String error);

src/main/java/flashcardCreator/FcCRequestModel.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
package flashcardCreator;
2+
/**
3+
* Request model for flashcard creator.
4+
* Application business rules.
5+
* @author Junyu Chen
6+
*/
7+
28

39
public class FcCRequestModel {
410
private int flashcardSetId;
511
private String term, definition;
12+
13+
/**
14+
* Create FcCRequestModel
15+
* @param flashcardSetId id of flashcard set which new flashcard will be added to
16+
* @param term term of the flashcard
17+
* @param definition definition of the flashcard
18+
*/
619
public FcCRequestModel(int flashcardSetId, String term, String definition){
720
this.definition = definition;
821
this.term = term;

src/main/java/flashcardCreator/FcCResponseModel.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
package flashcardCreator;
22

33
import java.time.LocalDateTime;
4-
4+
/**
5+
* Response model for flashcard creator.
6+
* Application business rules.
7+
* @author Junyu Chen
8+
*/
59
public class FcCResponseModel {
6-
private LocalDateTime creationDate;
10+
private final LocalDateTime creationDate;
711
private String term, definition;
812

13+
/**
14+
* Create FcCResponseModel
15+
* @param creationDate date of creation of the flashcard
16+
* @param term term of the flashcard
17+
* @param definition definition of the flashcard
18+
*/
919
public FcCResponseModel(LocalDateTime creationDate, String term, String definition) {
1020
this.creationDate = creationDate;
1121
this.term = term;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package flashcardCreator.fcCScreens;
2+
3+
import flashcardCreator.FcCInputBoundary;
4+
import flashcardCreator.FcCRequestModel;
5+
import flashcardCreator.FcCResponseModel;
6+
7+
/**
8+
* Controller for flashcard creator.
9+
* Interface adaptors.
10+
* @author Junyu Chen
11+
*/
12+
13+
public class FcCController {
14+
FcCInputBoundary inputBoundary;
15+
int flashcardSetId;
16+
17+
/**
18+
* Create FcCController
19+
* @param inputBoundary Interactor for flashcard creator.
20+
* @param flashcardSetId Id of flashcard set which new flashcard will be created in.
21+
*/
22+
public FcCController(FcCInputBoundary inputBoundary, int flashcardSetId){
23+
this.inputBoundary = inputBoundary;
24+
this.flashcardSetId = flashcardSetId;
25+
}
26+
public FcCResponseModel create(String term, String definition){
27+
return inputBoundary.create(new FcCRequestModel(flashcardSetId, term, definition));
28+
}
29+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package flashcardCreator.fcCScreens;
2+
/**
3+
* Failure of flashcard creator.
4+
* Interface Adaptors.
5+
* @author Junyu Chen
6+
*/
7+
public class FcCFailure extends RuntimeException{
8+
public FcCFailure(String error){
9+
super(error);
10+
}
11+
}

0 commit comments

Comments
 (0)