File tree Expand file tree Collapse file tree 5 files changed +16
-6
lines changed
src/main/java/seedu/duke/flashcard Expand file tree Collapse file tree 5 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -5,4 +5,4 @@ ddf | dfdf | - | - | -
5
5
hello | bye | - | - | -
6
6
hello | bye | - | - | -
7
7
end program | hello | - | - | -
8
- d | d | - | - | -
8
+ hello | world | - | - | -
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ public FlashcardComponent(ArrayList<Flashcard> flashcards) {
27
27
storage = new FlashcardStorage ("./data/flashcard.txt" );
28
28
try {
29
29
flashcardList = storage .loadFlashcards ();
30
- System .out .println ("Loading existed File" );
31
30
} catch (FileNotFoundException e ){
32
31
System .out .println ("Making New file" );
33
32
flashcardList = new FlashcardList (flashcards );
Original file line number Diff line number Diff line change @@ -20,12 +20,12 @@ public FlashcardDirectory(){
20
20
file = new File (path );
21
21
if (!file .exists ()){
22
22
if (file .mkdir ()){
23
- System .out .println ("Created data directory" );
23
+ System .out .println (" Created data directory" );
24
24
} else {
25
- System .out .println ("Failed to create directory" );
25
+ System .out .println (" Failed to create directory" );
26
26
}
27
27
} else {
28
- System .out .println ("Using data directory" );
28
+ System .out .println (" Using data directory" );
29
29
}
30
30
}
31
31
@@ -41,7 +41,7 @@ public void listFlashcardFiles(){
41
41
System .out .println ("No files exist" );
42
42
} else {
43
43
for (String flashcardFile : flashcardFiles ){
44
- System .out .println (flashcardFile );
44
+ System .out .println (" " + flashcardFile );
45
45
}
46
46
}
47
47
}
Original file line number Diff line number Diff line change @@ -15,6 +15,11 @@ public ArrayList<Flashcard> getFlashcards() {
15
15
return flashcards ;
16
16
}
17
17
18
+ // @@author junhyeong0411
19
+ public int getSize (){
20
+ return flashcards .size ();
21
+ }
22
+
18
23
19
24
public void add (Flashcard flashcard ) {
20
25
flashcards .add (flashcard );
Original file line number Diff line number Diff line change @@ -33,6 +33,9 @@ public boolean isStorageAvailable(){
33
33
* @return Flashcard object
34
34
*/
35
35
private Flashcard loadFlashcard (String [] tokens ){
36
+
37
+ assert tokens .length == 5 : "Token length should be 5" ;
38
+
36
39
String frontText = tokens [0 ].trim ();
37
40
String backText = tokens [1 ].trim ();
38
41
String [] tags = tokens [2 ].trim ().split ("/" );
@@ -82,11 +85,14 @@ public FlashcardList loadFlashcards() throws FileNotFoundException{
82
85
flashcardList .add (loadFlashcard (flashTokens ));
83
86
}
84
87
88
+ System .out .println (String .format (" There are currently %d flashcards in the savefile" , flashcardList .getSize ()));
89
+
85
90
return flashcardList ;
86
91
87
92
}
88
93
89
94
public void saveFlashcards (ArrayList <Flashcard > flashcardList ) {
95
+
90
96
try {
91
97
FileWriter fw = new FileWriter (path );
92
98
You can’t perform that action at this time.
0 commit comments