Skip to content

Commit 3e94866

Browse files
authored
Merge branch 'master' into master
2 parents 8083d7c + b346920 commit 3e94866

File tree

11 files changed

+29
-11
lines changed

11 files changed

+29
-11
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ checkstyle {
4141
toolVersion = '10.2'
4242
}
4343

44-
run{
44+
run {
4545
standardInput = System.in
4646
enableAssertions = true
4747
}

data/flashcard.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ ddf | dfdf | - | - | -
55
hello | bye | - | - | -
66
hello | bye | - | - | -
77
end program | hello | - | - | -
8+
hello | world | - | - | -

src/main/java/seedu/duke/Duke.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
import seedu.duke.flashcard.Flashcard;
66
import seedu.duke.flashcard.FlashcardComponent;
7-
import seedu.duke.calendar.Event;
87
import seedu.duke.calendar.CalendarManager;
8+
import seedu.duke.calendar.Event;
99

1010
import java.util.ArrayList;
1111
import java.util.Scanner;
@@ -18,7 +18,7 @@ public static void main(String[] args) {
1818
}
1919

2020
private void runCalendar() {
21-
System.out.print("Enter your command: ");
21+
System.out.println("Enter your command: ");
2222

2323
CalendarManager manager = new CalendarManager(new ArrayList<Event>());
2424

@@ -72,7 +72,7 @@ private void run() {
7272
String flashcardOrCalendar;
7373
Scanner scanner = new Scanner(System.in);
7474

75-
System.out.print("Do you choose flashcard or calendar? ");
75+
System.out.println("Do you choose flashcard or calendar? ");
7676
flashcardOrCalendar = scanner.nextLine();
7777

7878
if (flashcardOrCalendar.equals("flashcard")) {

src/main/java/seedu/duke/flashcard/FlashcardComponent.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public FlashcardComponent(ArrayList<Flashcard> flashcards) {
2727
storage = new FlashcardStorage("./data/flashcard.txt");
2828
try {
2929
flashcardList = storage.loadFlashcards();
30-
System.out.println("Loading existed File");
3130
} catch (FileNotFoundException e){
3231
System.out.println("Making New file");
3332
flashcardList = new FlashcardList(flashcards);

src/main/java/seedu/duke/flashcard/FlashcardDirectory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ public FlashcardDirectory(){
2020
file = new File(path);
2121
if(!file.exists()){
2222
if(file.mkdir()){
23-
System.out.println("Created data directory");
23+
System.out.println(" Created data directory");
2424
} else{
25-
System.out.println("Failed to create directory");
25+
System.out.println(" Failed to create directory");
2626
}
2727
} else{
28-
System.out.println("Using data directory");
28+
System.out.println(" Using data directory");
2929
}
3030
}
3131

@@ -41,7 +41,7 @@ public void listFlashcardFiles(){
4141
System.out.println("No files exist");
4242
} else{
4343
for(String flashcardFile : flashcardFiles){
44-
System.out.println(flashcardFile);
44+
System.out.println(" "+flashcardFile);
4545
}
4646
}
4747
}

src/main/java/seedu/duke/flashcard/FlashcardList.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public ArrayList<Flashcard> getFlashcards() {
1515
return flashcards;
1616
}
1717

18+
// @@author junhyeong0411
19+
public int getSize(){
20+
return flashcards.size();
21+
}
22+
1823

1924
public void add(Flashcard flashcard) {
2025
flashcards.add(flashcard);

src/main/java/seedu/duke/flashcard/FlashcardStorage.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public boolean isStorageAvailable(){
3333
* @return Flashcard object
3434
*/
3535
private Flashcard loadFlashcard(String[] tokens){
36+
37+
assert tokens.length == 5: "Token length should be 5";
38+
3639
String frontText = tokens[0].trim();
3740
String backText = tokens[1].trim();
3841
String[] tags = tokens[2].trim().split("/");
@@ -82,11 +85,16 @@ public FlashcardList loadFlashcards() throws FileNotFoundException{
8285
flashcardList.add(loadFlashcard(flashTokens));
8386
}
8487

88+
System.out.println(String.format(
89+
" There are currently %d flashcards in the savefile",
90+
flashcardList.getSize()));
91+
8592
return flashcardList;
8693

8794
}
8895

8996
public void saveFlashcards(ArrayList<Flashcard> flashcardList) {
97+
9098
try {
9199
FileWriter fw = new FileWriter(path);
92100

text-ui-test/ACTUAL.TXT

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Do you choose flashcard or calendar?
2+
Enter your command:

text-ui-test/EXPECTED-UNIX.TXT

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Do you choose flashcard or calendar?
2+
Enter your command:

text-ui-test/EXPECTED.TXT

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Enter the front page text:
1+
Do you choose flashcard or calendar?
2+
Enter your command:

0 commit comments

Comments
 (0)