Skip to content

Commit

Permalink
Removed all warnings in edit main page. Removed warnings in InMemoryF…
Browse files Browse the repository at this point in the history
…lashcardSet.java
  • Loading branch information
ThomasShimUoft committed Dec 5, 2022
1 parent e003151 commit 9aee17c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ public void editTitleAndDescription(FlashcardSetDsRequestModel flashcardSet) {
@Override
public void saveFlashcardID(int flashcardSetId, int flashcardId) {
FlashcardSetDsRequestModel oldFlashcardSet = flashcardSets.get(flashcardSetId);
String title = oldFlashcardSet.getTitle();
String description = oldFlashcardSet.getDescription();
boolean isPrivate = oldFlashcardSet.getIsPrivate();
List<Integer> flashcardIds = oldFlashcardSet.getFlashcardIds();
String owner = oldFlashcardSet.getOwnerUsername();

ArrayList<Integer> newFlashcardIds = new ArrayList<>(flashcardIds);
newFlashcardIds.add(flashcardId);
FlashcardSetDsRequestModel newFlashcardSet = new FlashcardSetDsRequestModel(title, description, isPrivate, flashcardSetId, owner, newFlashcardIds);
FlashcardSetDsRequestModel newFlashcardSet = new FlashcardSetDsRequestModel(
oldFlashcardSet.getTitle(),
oldFlashcardSet.getDescription(),
oldFlashcardSet.getIsPrivate(),
flashcardSetId,
oldFlashcardSet.getOwnerUsername(),
newFlashcardIds);

flashcardSets.put(flashcardSetId, newFlashcardSet);
}
Expand All @@ -77,15 +79,16 @@ public void saveFlashcardID(int flashcardSetId, int flashcardId) {
@Override
public void removeFlashcardId(int flashcardSetId, int flashcardId) {
FlashcardSetDsRequestModel oldFlashcardSet = flashcardSets.get(flashcardSetId);
String title = oldFlashcardSet.getTitle();
String description = oldFlashcardSet.getDescription();
boolean isPrivate = oldFlashcardSet.getIsPrivate();
List<Integer> flashcardIds = oldFlashcardSet.getFlashcardIds();
String owner = oldFlashcardSet.getOwnerUsername();

ArrayList<Integer> newFlashcardIds = new ArrayList<>(flashcardIds);
newFlashcardIds.remove(flashcardId);
FlashcardSetDsRequestModel newFlashcardSet = new FlashcardSetDsRequestModel(title, description, isPrivate, flashcardSetId, owner, newFlashcardIds);
FlashcardSetDsRequestModel newFlashcardSet = new FlashcardSetDsRequestModel(
oldFlashcardSet.getTitle(),
oldFlashcardSet.getDescription(),
oldFlashcardSet.getIsPrivate(),
flashcardSetId,
oldFlashcardSet.getOwnerUsername(),
newFlashcardIds);

flashcardSets.put(flashcardSetId, newFlashcardSet);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public ListOfFlashcardsDataPanel(DBGateway dbGateway, List<FlashcardDsRequestMod
int numCards = flashcardData.size();
if (numCards == 0){
JLabel label = new JLabel("You have no Flashcards in this FlashcardSet.");
//label.setHorizontalAlignment(SwingConstants.CENTER);
//label.setVerticalAlignment(SwingConstants.TOP);
JPanel labelPanel = new JPanel();
labelPanel.add(label);
flashcardPanels.add(labelPanel);
Expand Down

0 comments on commit 9aee17c

Please sign in to comment.