Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Test Cases for Deck Related Commands and Home Command. #132

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,11 @@ public CommandResult execute(Model model) throws CommandException {

return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd.getDeckName()));
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof AddDeckCommand // instanceof handles nulls
&& toAdd.equals(((AddDeckCommand) other).toAdd));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public CommandResult execute(Model model) {

@Override
public boolean equals(Object other) {
return other == this; // short circuit if same object
return other == this || (other instanceof HomeCommand);
}
}
4 changes: 1 addition & 3 deletions src/main/java/seedu/flashnotes/model/FlashNotes.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ public void addDeck(Deck card) {
*/
public void setDeck(Deck target, Deck editedDeck) {
requireNonNull(editedDeck);

decks.setDeck(target, editedDeck);
//TODO update the flashcards if there are existing flashcardsun
}

/**
Expand Down Expand Up @@ -260,8 +260,6 @@ public ObservableList<Flashcard> getFlashcardList() {

@Override
public ObservableList<Deck> getDeckList() {
//todo read the tags and update
//todo change when we have decklist implementation up
return decks.asUnmodifiableObservableList();
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/java/seedu/flashnotes/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ public boolean hasDeck(Deck deck) {

@Override
public void deleteDeck(Deck target) {
//todo delete deck - PX
flashNotes.removeDeck(target);
updateFilteredDeckList(PREDICATE_SHOW_ALL_DECKS);
}
Expand All @@ -130,7 +129,6 @@ public void addDeck(Deck deck) {
@Override
public void setDeck(Deck target, Deck editedDeck) {
flashNotes.setDeck(target, editedDeck);

}

@Override
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/seedu/flashnotes/model/deck/Deck.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

import java.util.Objects;


/**
* Deck is the tag which is given to every card.
*/
public class Deck {
public static final String MESSAGE_CONSTRAINTS =
"DeckName should not be blank";
Expand Down Expand Up @@ -32,10 +34,12 @@ public String getResultStatistics() {
}

public void setDeckName(String deckName) {
requireNonNull(deckName);
this.deckName = deckName;
}

public void setResultStatistics(String resultStatistics) {
requireNonNull(resultStatistics);
this.resultStatistics = resultStatistics;
}

Expand All @@ -56,7 +60,6 @@ public boolean isSameDeck(Deck otherDeck) {

return otherDeck != null
&& otherDeck.getDeckName().equals(getDeckName());
//&& (otherDeck.getResultStatistics().equals(getResultStatistics()));
}
@Override
public boolean equals(Object o) {
Expand All @@ -67,11 +70,11 @@ public boolean equals(Object o) {
return false;
}
Deck deck = (Deck) o;
return Objects.equals(deckName, deck.deckName); //&& Objects.equals(resultStatistics, deck.resultStatistics);
return Objects.equals(deckName, deck.deckName);
}

@Override
public int hashCode() {
return Objects.hash(deckName); //, resultStatistics);
return Objects.hash(deckName);
}
}
18 changes: 11 additions & 7 deletions src/test/java/seedu/flashnotes/logic/commands/AddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,17 @@ public boolean hasDeck(Deck deck) {

@Override
public void deleteDeck(Deck target) {

throw new AssertionError("This method should not be called.");
}

@Override
public void addDeck(Deck deck) {

throw new AssertionError("This method should not be called.");
}

@Override
public void setDeck(Deck target, Deck editedDeck) {

throw new AssertionError("This method should not be called.");
}

@Override
Expand All @@ -166,17 +166,17 @@ public boolean getIsInDeck() {

@Override
public void setIsInDeckTrue() {

throw new AssertionError("This method should not be called.");
}

@Override
public void setIsInDeckFalse() {

throw new AssertionError("This method should not be called.");
}

@Override
public void setCurrentDeckName(String deckName) {

throw new AssertionError("This method should not be called.");
}

@Override
Expand All @@ -191,7 +191,7 @@ public ObservableList<Deck> getFilteredDeckList() {

@Override
public void updateFilteredDeckList(Predicate<Deck> predicate) {

throw new AssertionError("This method should not be called.");
}

@Override
Expand Down Expand Up @@ -276,6 +276,10 @@ public void addFlashcard(Flashcard flashcard) {
flashcardsAdded.add(flashcard);
}

@Override
public void addDeck(Deck deck) {
requireNonNull(deck);
}
@Override
public ReadOnlyFlashNotes getFlashNotes() {
return new FlashNotes();
Expand Down