Skip to content

Commit

Permalink
Merge pull request nus-cs2113-AY2324S1#17 from junhyeong0411/master
Browse files Browse the repository at this point in the history
Make format of flashcard Directory
  • Loading branch information
junhyeong0411 authored Oct 18, 2023
2 parents 85ff53a + ba639f3 commit 93ae4b1
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/seedu/duke/flashcard/FlashcardDirectory.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
/**
* directory for flashcards
* can list-up txt files in text folder
* In version 1, using only flashcard.txt
* In version 2, can select or create
*/

public class FlashcardDirectory {
Expand Down Expand Up @@ -45,4 +47,23 @@ public void listFlashcardFiles(){
}
}

/**
* return default directory
* for version 1
* @return directory for flashcard txt file
*/
public String defaultDirectory() {
return this.path + "/flashcard.txt";
}

/**
* return directory of flashcard txt file
* for version 2
* @param path
* @return
*/
public String flashcardDirectory(String path) {
return this.path + path;
}

}
15 changes: 15 additions & 0 deletions src/main/java/seedu/duke/flashcard/FlashcardStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public FlashcardStorage(String path){
}


/**
* load a flash card from certain format
* Tokens includes attributes of Flashcard
* @param tokens
* @return Flashcard object
*/
private Flashcard loadFlashcard(String[] tokens){
String frontText = tokens[0].trim();
String backText = tokens[1].trim();
Expand Down Expand Up @@ -56,6 +62,12 @@ private Flashcard loadFlashcard(String[] tokens){
return flashcard;
}

/**
* load list of flashcards
* from this.path
* @return list of Flashcards
* @throws FileNotFoundException
*/
public FlashcardList loadFlashcards() throws FileNotFoundException{
FlashcardList flashcardList = new FlashcardList(new ArrayList<>());
File f = new File (this.path);
Expand Down Expand Up @@ -84,4 +96,7 @@ public void saveFlashcards(ArrayList<Flashcard> flashcardList) {
System.out.println("Failed to save.");
}
}



}

0 comments on commit 93ae4b1

Please sign in to comment.