Skip to content

Commit 760f0db

Browse files
Merge branch 'main' of https://github.com/CSC207-2022F-UofT/course-project-team-bbq into Anthony's_Branch
2 parents 82b72e2 + a25ea1a commit 760f0db

26 files changed

+479
-125
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.

src/main/java/create_flashcard_set_use_case/CreationScreen.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package create_flashcard_set_use_case;
22

33
import login_and_signup_use_case.UserLoginResponseModel;
4-
import view.Screen;
54

65
import javax.swing.*;
76
import java.awt.*;
@@ -11,13 +10,18 @@
1110

1211
// Frameworks/Drivers (Blue) layer
1312

14-
public class CreationScreen extends Screen implements ActionListener {
13+
/**
14+
* The flashcard set creation screen.
15+
*
16+
* @author Edward Ishii
17+
*/
18+
public class CreationScreen extends JFrame implements ActionListener {
1519
/**
16-
* The title of the flashcard set chosen by the user
20+
* The title of the flashcard set chosen by the user.
1721
*/
1822
JTextField title = new JTextField(15);
1923
/**
20-
* The description of the flashcard set
24+
* The description of the flashcard set.
2125
*/
2226
JTextField description = new JTextField(15);
2327
// /**
@@ -26,10 +30,13 @@ public class CreationScreen extends Screen implements ActionListener {
2630
// JTextField username = new JTextField(15);
2731

2832
/**
29-
* The controller
33+
* The controller.
3034
*/
3135
FlashcardSetController flashcardSetController;
3236

37+
/**
38+
* The user.
39+
*/
3340
UserLoginResponseModel user;
3441

3542
private boolean privateSelected; // for public or private status of flashcard set
@@ -93,10 +100,10 @@ public void actionPerformed(ActionEvent evt) {
93100
privateSelected = !privateSelected; // toggle every time clicked
94101
} else {
95102
try {
96-
flashcardSetController.create(title.getText(), description.getText(),
97-
privateSelected, user.getSignedInUsername());
103+
FlashcardSetResponseModel responseModel = flashcardSetController.create(title.getText(),
104+
description.getText(), privateSelected, user.getSignedInUsername());
98105
JOptionPane.showMessageDialog(this,
99-
String.format("Flashcard Set: [%s] created.", title.getText()));
106+
String.format("Flashcard Set: [%s] has been created.", responseModel.getFs().getTitle()));
100107
this.dispose(); // exit creation screen
101108
} catch (FlashcardSetCreationFailed e) {
102109
JOptionPane.showMessageDialog(this, e.getMessage());

src/main/java/delete_flashcard_set_use_case/DelFlashcardSetInteractor.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// Use case (Red) layer
44

55
import data_access.DBGateway;
6-
import data_access.IFlashcardDataAccess;
7-
import data_access.IFlashcardSetDataAccess;
86

97
/**
108
* [Feature: Deleting a Flashcard Set]
@@ -21,8 +19,7 @@
2119
public class DelFlashcardSetInteractor implements DelFlashcardSetInputBoundary {
2220

2321
DBGateway dbGateway;
24-
IFlashcardSetDataAccess flashcardSetDataAccess; // for testing
25-
IFlashcardDataAccess flashcardDataAccess; // for testing
22+
2623
DelFlashcardSetOutputBoundary outputBoundary;
2724

2825
public DelFlashcardSetInteractor(DBGateway dbGateway, DelFlashcardSetOutputBoundary outputBoundary) {

src/main/java/delete_flashcard_set_use_case/DeletionScreen.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package delete_flashcard_set_use_case;
22

3-
43
import data_access.DBGateway;
54
import login_and_signup_use_case.UserLoginResponseModel;
6-
import view.Screen;
75

86
import javax.swing.*;
97
import java.awt.*;
@@ -13,18 +11,30 @@
1311

1412
// Frameworks/Drivers (Blue) layer
1513

16-
public class DeletionScreen extends Screen implements ActionListener {
14+
/**
15+
* The flashcard set deletion screen.
16+
*
17+
* @author Edward Ishii
18+
*/
19+
public class DeletionScreen extends JFrame implements ActionListener {
1720
/**
18-
* The id of the flashcard set to be deleted
21+
* The id of the flashcard set to be deleted.
1922
*/
2023
int flashcardSetID;
2124

25+
/**
26+
* The user.
27+
*/
2228
UserLoginResponseModel user;
2329

2430
/**
25-
* The controller
31+
* The controller.
2632
*/
2733
DelFlashcardSetController controller;
34+
35+
/**
36+
* The database gateway.
37+
*/
2838
DBGateway gateway;
2939

3040
// /**
@@ -37,7 +47,7 @@ public class DeletionScreen extends Screen implements ActionListener {
3747
*/
3848
public DeletionScreen(int flashcardSetID, DelFlashcardSetController controller, UserLoginResponseModel user,
3949
DBGateway gateway) {
40-
this.user=user;
50+
this.user = user;
4151
this.flashcardSetID = flashcardSetID;
4252
this.controller = controller;
4353
this.gateway = gateway;
@@ -78,19 +88,16 @@ public void actionPerformed(ActionEvent evt) {
7888
// Exit deletion screen if user cancels deletion
7989
if (Objects.equals(evt.getActionCommand(), "Cancel")) {
8090
this.dispose();
81-
}
82-
83-
else { // Delete was pressed
91+
} else { // Delete was pressed
8492
// try {
8593
// int id = Integer.parseInt(flashcardSetID.getText()); // check input is an integer
8694

8795
// Ask for confirmation
8896
String title;
8997
// Admin deletion
90-
if (user.getFlashcardSets().get(flashcardSetID) == null){
91-
title = gateway.getFlashcardSet(flashcardSetID).getTitle();
92-
}
93-
else{
98+
if (user.getFlashcardSets().get(flashcardSetID) == null) {
99+
title = gateway.getFlashcardSet(flashcardSetID).getTitle();
100+
} else {
94101
// User deletion
95102
title = user.getFlashcardSets().get(flashcardSetID)[0];
96103
}
@@ -101,8 +108,9 @@ public void actionPerformed(ActionEvent evt) {
101108
"Confirmation", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
102109
if (confirmation == 0) {
103110
try {
104-
controller.delete(flashcardSetID);
105-
JOptionPane.showMessageDialog(this, title + " has been deleted.");
111+
DelFlashcardSetResponseModel responseModel = controller.delete(flashcardSetID);
112+
responseModel.setMessage(title + " has been deleted.");
113+
JOptionPane.showMessageDialog(this, responseModel.getMessage());
106114
this.dispose(); // exit deletion screen
107115
} catch (FlashcardSetNotFound e) {
108116
JOptionPane.showMessageDialog(this, e.getMessage());

src/main/java/editor_main_page/FlashcardDataPanel.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ else if(event.getActionCommand().equals("Delete Flashcard")){
6969
@Override
7070
public void windowOpened(WindowEvent e) {}
7171
@Override
72-
public void windowClosing(WindowEvent e) {}
73-
@Override
74-
public void windowClosed(WindowEvent e) {
72+
public void windowClosing(WindowEvent e) {
7573
//When observing a window close we refresh the page.
7674
frame.dispose();
7775
new EditorMainPage(flashcardSetId);
7876
}
7977
@Override
78+
public void windowClosed(WindowEvent e) {}
79+
@Override
8080
public void windowIconified(WindowEvent e) {}
8181
@Override
8282
public void windowDeiconified(WindowEvent e) {}

src/main/java/entities/CommonUser.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,61 @@ public CommonUser(String username, String password, boolean isAdmin){
3333
this.flashcardSetIds = new ArrayList<>();
3434
}
3535

36-
//GETTERS AND SETTERS
36+
/**
37+
* Gets the username of the user
38+
* @return the username of the user
39+
*/
3740
@Override
3841
public String getUsername() {
3942
return username;
4043
}
4144

45+
/**
46+
* Sets the username of the user to be as given.
47+
* @param username the username of the use
48+
*/
4249
public void setUsername(String username) {
4350
this.username = username;
4451
}
4552

53+
/**
54+
* Gets the password of the user
55+
* @return the password of the user
56+
*/
4657
@Override
4758
public String getPassword() {
4859
return password;
4960
}
5061

62+
/**
63+
* Sets the password of the user to be as given.
64+
* @param password the username of the use
65+
*/
5166
public void setPassword(String password) {
5267
this.password = password;
5368
}
5469

70+
/**
71+
* Gets the admin access level of the user
72+
* @return whether the user is an admin
73+
*/
5574
@Override
5675
public boolean getIsAdmin() {
5776
return isAdmin;
5877
}
5978

79+
/**
80+
* Sets the level of admin access the user has
81+
* @param isAdmin whether the user should obtain admin level access
82+
*/
6083
public void setIsAdmin(boolean isAdmin){
6184
this.isAdmin = isAdmin;
6285
}
6386

87+
/**
88+
* Gets the list of flashcard set ids belonging to the user
89+
* @return list of flashcard set ids
90+
*/
6491
@Override
6592
public ArrayList<Integer> getFlashcardSetIds() {
6693
return flashcardSetIds;
@@ -77,7 +104,7 @@ public boolean passwordIsValid() {
77104

78105
/**
79106
* Checks whether the admin key entered is similar to the actual admin key in the business rules
80-
* @param adminKey the username of the use
107+
* @param adminKey the username of the user
81108
* @return whether the admin is the same as the one stored in the enterprise rules
82109
*/
83110
@Override

src/main/java/entities/User.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,27 @@
1010
*/
1111
public interface User {
1212
String username = null;
13-
1413
String password = null;
1514
boolean isAdmin = false;
16-
String ADMIN_KEY = "BuiltDifferent";
17-
18-
//Map<Integer, String[]> flashcardSets = null;
19-
ArrayList<Integer> flashcardSetIds = null;
2015

16+
/**
17+
* Gets the username belonging to the user
18+
*/
2119
String getUsername();
2220

21+
/**
22+
* Gets the password belonging to the user
23+
*/
2324
String getPassword();
2425

26+
/**
27+
* Gets whether the user is an admin user
28+
*/
2529
boolean getIsAdmin();
2630

31+
/**
32+
* Gets the list of flashcard set ids belonging to the user
33+
*/
2734
ArrayList<Integer> getFlashcardSetIds();
2835

2936
/**

src/main/java/login_and_signup_use_case/UserLoginInteractor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public UserLoginResponseModel login(UserLoginRequestModel userLoginRequestModel)
4545
}
4646

4747
UserLoginResponseModel accountResponseModel = new UserLoginResponseModel(tempUser.getUsername(),
48+
tempUser.getPassword(),
4849
tempUser.getIsAdmin(), flashcardSets);
4950
return userLoginOutputBoundary.prepareSuccessView(accountResponseModel);
5051
}

src/main/java/login_and_signup_use_case/UserLoginRequestModel.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,17 @@ public UserLoginRequestModel(String username, String password) {
2121
}
2222

2323
/**
24-
* GETTERS AND SETTERS
24+
* Gets the inputted username of the user
25+
* @return the username that the user inputted
2526
*/
2627
String getUsername() {
2728
return username;
2829
}
2930

31+
/**
32+
* Sets the inputted password of the user to be as given.
33+
* @return the password that the user inputted
34+
*/
3035
String getPassword() {
3136
return password;
3237
}

src/main/java/login_and_signup_use_case/UserLoginResponseModel.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
public class UserLoginResponseModel {
1111
String username;
1212

13+
String password;
14+
1315
boolean isAdmin;
1416

1517
Map<Integer, String[]> flashcardSets;
@@ -21,20 +23,38 @@ public class UserLoginResponseModel {
2123
* @param flashcardSets the flashcard sets map pertaining to the user obtained by the login interactor, where each id
2224
* pertains to its title and description
2325
*/
24-
public UserLoginResponseModel(String loggedInUsername, boolean isAdmin, Map<Integer, String[]> flashcardSets){
26+
public UserLoginResponseModel(String loggedInUsername, String password, boolean isAdmin, Map<Integer, String[]> flashcardSets){
2527
this.username = loggedInUsername;
28+
this.password = password;
2629
this.isAdmin = isAdmin;
2730
this.flashcardSets = flashcardSets;
2831
}
2932

3033
/**
31-
* GETTERS for the system
34+
* Gets the username of the user as saved in the database
35+
* @return the username that the user stored
3236
*/
3337
public String getSignedInUsername() {
3438
return username;
3539
}
40+
41+
/**
42+
* Gets the password of the user as saved in the database
43+
* @return the password that the user stored
44+
*/
45+
public String getPassword() { return password; }
46+
47+
/**
48+
* Gets whether the user is saved as an admin in the database
49+
* @return the admin level access of the user as stored in the database
50+
*/
3651
public boolean getIsAdmin(){return isAdmin;}
3752

53+
/**
54+
* Gets the list of flashcard set ids belonging to the user and onverts it into a map with the id as
55+
* a key and the title and description of the flashcard set as the value in a string array format
56+
* @return map of the flashcard sets belonging to the user
57+
*/
3858
public Map<Integer, String[]> getFlashcardSets(){
3959

4060
return flashcardSets;

0 commit comments

Comments
 (0)