Skip to content

Commit 141ef7e

Browse files
authored
Merge pull request #93 from CSC207-2022F-UofT/8-feature-main-home-page
completed java doc for database classes, database interfaces, and home page
2 parents 896cc19 + 977de3b commit 141ef7e

File tree

10 files changed

+415
-126
lines changed

10 files changed

+415
-126
lines changed
Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,58 @@
11
package data_access_use_case.entity_request_models;
22

33
import java.util.List;
4+
/**
5+
* Common User Request Model.
6+
* Application Business Rules
7+
* @author Justin Li
8+
*/
49

510
public class CommonUserDsRequestModel {
611
private final String username;
712
private final String password;
813
private final boolean isAdmin;
914
private final List<Integer> flashcardSetIds;
1015

16+
/**
17+
* Creates a flashcard response model based on the following parameters.
18+
* @param username the user's username.
19+
* @param password the user's password.
20+
* @param isAdmin true if the user is an admin user.
21+
* @param flashcardSetIds the list of flashcard set ids created by the user.
22+
*/
1123
public CommonUserDsRequestModel(String username, String password, boolean isAdmin, List<Integer> flashcardSetIds){
1224
this.username = username;
1325
this.password = password;
1426
this.isAdmin = isAdmin;
1527
this.flashcardSetIds = flashcardSetIds;
1628
}
29+
30+
/**
31+
* Gets the username of the user
32+
* @return the username of the user
33+
*/
1734
public String getUsername(){
1835
return username;
1936
}
20-
37+
/**
38+
* Gets the password of the user
39+
* @return the password of the user
40+
*/
2141
public String getPassword(){
2242
return password;
2343
}
24-
44+
/**
45+
* Gets if the user is an admin user
46+
* @return true if the user is an admin user.
47+
*/
2548
public boolean getIsAdmin(){
2649
return isAdmin;
2750
}
28-
51+
/**
52+
* Gets the list of flashcard set ids created by the user
53+
* @return the list of flashcard set ids created by the user
54+
*/
2955
public List<Integer> getFlashcardSetIds(){
30-
return flashcardSetIds ;
56+
return flashcardSetIds;
3157
}
3258
}

src/main/java/data_access_use_case/entity_request_models/FlashcardDsRequestModel.java

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package data_access_use_case.entity_request_models;
2-
// use case layer
32

43
import java.time.LocalDateTime;
4+
/**
5+
* Flashcard Request Model.
6+
* Application Business Rules
7+
* @author Justin Li
8+
*/
59

610
public class FlashcardDsRequestModel {
711
private String term;
@@ -10,6 +14,14 @@ public class FlashcardDsRequestModel {
1014
private int flashcardId;
1115
private final int belongsToId;
1216

17+
/**
18+
* Creates a flashcard response model based on the following parameters.
19+
* @param term the flashcard term
20+
* @param definition the flashcard definition for the term
21+
* @param creationDate the time the flashcard is created (time formatted in LocalDateTime)
22+
* @param flashcardId the flashcard id
23+
* @param belongsToId the id of the flashcard set that the flashcard is in.
24+
*/
1325
public FlashcardDsRequestModel(String term, String definition, LocalDateTime creationDate,
1426
int flashcardId, int belongsToId){
1527
this.term = term;
@@ -18,33 +30,54 @@ public FlashcardDsRequestModel(String term, String definition, LocalDateTime cre
1830
this.flashcardId = flashcardId;
1931
this.belongsToId = belongsToId;
2032
}
33+
/**
34+
* Gets the flashcard term.
35+
* @return the flashcard term
36+
*/
2137
public String getTerm() {
2238
return term;
2339
}
24-
40+
/**
41+
* Gets the flashcard definition.
42+
* @return the flashcard definition.
43+
*/
2544
public String getDefinition() {
2645
return definition;
2746
}
28-
47+
/**
48+
* Gets the flashcard creation date.
49+
* @return the flashcard creation date in LocalDateTime formatting.
50+
*/
2951
public LocalDateTime getCreationDate() {
3052
return creationDate;
3153
}
32-
54+
/**
55+
* Gets the flashcard id.
56+
* @return the flashcard id.
57+
*/
3358
public int getFlashcardId(){
3459
return flashcardId;
3560
}
36-
61+
/**
62+
* Gets the id of the flashcard set that the flashcard belongs to.
63+
* @return the id of the flashcard set that the flashcard belongs to.
64+
*/
3765
public int getBelongsToId(){
3866
return belongsToId;
3967
}
40-
public void setTerm(String term) {
41-
this.term = term;
42-
}
43-
68+
/**
69+
* Sets the term.
70+
*/
71+
public void setTerm(String term) {this.term = term;}
72+
/**
73+
* Sets the definition.
74+
*/
4475
public void setDefinition(String definition) {
4576
this.definition = definition;
4677
}
47-
78+
/**
79+
* Sets the flashcard id.
80+
*/
4881
public void setFlashcardId(int flashcardId) {
4982
this.flashcardId = flashcardId;
5083
}

src/main/java/data_access_use_case/entity_request_models/FlashcardSetDsRequestModel.java

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package data_access_use_case.entity_request_models;
22

33
import java.util.List;
4+
/**
5+
* Flashcard Set Request Model.
6+
* Application Business Rules
7+
* @author Justin Li
8+
*/
49

510
public class FlashcardSetDsRequestModel {
611
private String title;
@@ -11,6 +16,14 @@ public class FlashcardSetDsRequestModel {
1116
private final String ownerUsername;
1217
private int flashcardSetId;
1318

19+
/**
20+
* Creates a flashcard response model based on the following parameters.
21+
* @param title the flashcard set title
22+
* @param description the flashcard set description.
23+
* @param isPrivate true if the flashcard set is private.
24+
* @param flashcardSetId the flashcard set id
25+
* @param ownerUsername the id of the user that created the flashcard set.
26+
*/
1427
public FlashcardSetDsRequestModel(String title, String description, boolean isPrivate,
1528
int flashcardSetId, String ownerUsername,
1629
List<Integer> flashcardIds){
@@ -21,38 +34,63 @@ public FlashcardSetDsRequestModel(String title, String description, boolean isPr
2134
this.ownerUsername = ownerUsername;
2235
this.flashcardIds = flashcardIds;
2336
}
37+
/**
38+
* Gets the flashcard set title.
39+
* @return the flashcard set title.
40+
*/
2441
public String getTitle() {
2542
return title;
2643
}
27-
44+
/**
45+
* Gets the flashcard set description.
46+
* @return the flashcard set description.
47+
*/
2848
public String getDescription() {
2949
return description;
3050
}
31-
51+
/**
52+
* Gets the flashcard privacy.
53+
* @return true if the flashcard set is private.
54+
*/
3255
public Boolean getIsPrivate() {
3356
return isPrivate;
3457
}
35-
58+
/**
59+
* Gets the flashcard set id.
60+
* @return the flashcard set id.
61+
*/
3662
public int getFlashcardSetId(){
3763
return flashcardSetId;
3864
}
39-
65+
/**
66+
* Gets the id of the user who created the flashcard set.
67+
* @return the if of the user who created the flashcard set.
68+
*/
4069
public String getOwnerUsername(){
4170
return ownerUsername;
4271
}
43-
72+
/**
73+
* Gets a list of all the flashcards in the flashcard set.
74+
* @return a list of all the flashcards in the flashcard set.
75+
*/
4476
public List<Integer> getFlashcardIds(){
4577
return flashcardIds;
4678
}
47-
79+
/**
80+
* Sets the flashcard set title.
81+
*/
4882
public void setTitle(String title) {
4983
this.title = title;
5084
}
51-
85+
/**
86+
* Sets the flashcard set description.
87+
*/
5288
public void setDescription(String description) {
5389
this.description = description;
5490
}
55-
91+
/**
92+
* Sets the flashcard set id.
93+
*/
5694
public void setFlashcardSetId(int flashcardSetId) {
5795
this.flashcardSetId = flashcardSetId;
5896
}

src/main/java/frameworks_and_drivers/components/FlashcardSetDataPanel.java

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,53 @@
2222
import java.awt.event.WindowEvent;
2323
import java.awt.event.WindowListener;
2424

25+
/**
26+
* Abstract class that represents a panel for an individual flashcard set.
27+
* This panel includes buttons for study, edit, test, and delete.
28+
* Frameworks & Drivers
29+
* @author Justin Li
30+
*/
2531
public class FlashcardSetDataPanel extends JPanel implements WindowListener {
32+
/**
33+
* The main JFrame that the flashcard set data panel will lie in.
34+
*/
2635
HomeScreen home;
36+
37+
/**
38+
* Creates a FlashcardSetDataPanel object that includes the title, description, flashcardSetId, gateway,
39+
* user, and home.
40+
* @param title the title of the flashcard set.
41+
* @param description the description of the flashcard set.
42+
* @param flashcardSetId the flashcard set id.
43+
* @param gateway the gateway to reach the flashcard set.
44+
* @param user the user that owns that flashcard set.
45+
* @param home the home screen containing the flashcard set panel.
46+
*/
2747
public FlashcardSetDataPanel(String title, String description,
2848
int flashcardSetId, DBGateway gateway,
2949
UserLoginResponseModel user, HomeScreen home) {
50+
// Panel Construction
3051
Border border = BorderFactory.createTitledBorder(title);
3152

32-
3353
JLabel descriptionLabel = new JLabel(description);
3454
this.add(descriptionLabel);
3555
this.home = home;
56+
57+
// Button Construction
3658
JPanel buttons = new JPanel();
3759

3860
JButton study = new JButton("Study");
3961
buttons.add(study);
62+
4063
JButton test = new JButton("Test");
4164
buttons.add(test);
65+
4266
JButton edit = new JButton("Edit");
4367
JButton delete = new JButton("Delete");
44-
45-
4668
buttons.add(edit);
4769
buttons.add(delete);
4870

71+
// Action listeners for edit, study, test, and delete buttons.
4972
edit.addActionListener((e) -> {
5073
EditorMainScreen editor = new EditorMainScreen(flashcardSetId);
5174
editor.addWindowListener(this);
@@ -77,39 +100,21 @@ public FlashcardSetDataPanel(String title, String description,
77100
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
78101
}
79102

80-
81103
@Override
82-
public void windowOpened(WindowEvent e) {
83-
84-
}
85-
104+
public void windowOpened(WindowEvent e) {}
86105
@Override
87-
public void windowClosing(WindowEvent e) {
88-
}
89-
106+
public void windowClosing(WindowEvent e) {}
90107
@Override
91108
public void windowClosed(WindowEvent e) {
109+
// When a window is closed the page will be refreshed.
92110
home.refresh();
93-
94111
}
95-
96112
@Override
97-
public void windowIconified(WindowEvent e) {
98-
99-
}
100-
113+
public void windowIconified(WindowEvent e) {}
101114
@Override
102-
public void windowDeiconified(WindowEvent e) {
103-
104-
}
105-
115+
public void windowDeiconified(WindowEvent e) {}
106116
@Override
107-
public void windowActivated(WindowEvent e) {
108-
109-
}
110-
117+
public void windowActivated(WindowEvent e) {}
111118
@Override
112-
public void windowDeactivated(WindowEvent e) {
113-
114-
}
119+
public void windowDeactivated(WindowEvent e) {}
115120
}

0 commit comments

Comments
 (0)