1
- //@@author wendelinwemhoener & kherlenbayasgalan
1
+ //@@author wendelinwemhoener
2
2
3
3
package seedu .duke ;
4
4
5
- import seedu .duke .flashcard .Flashcard ;
6
- import seedu .duke .flashcard .FlashcardComponent ;
7
5
import seedu .duke .calendar .CalendarManager ;
8
- import seedu .duke .calendar . Event ;
6
+ import seedu .duke .flashcard . FlashcardComponent ;
9
7
10
8
import java .util .ArrayList ;
11
9
import java .util .Scanner ;
@@ -17,71 +15,25 @@ public static void main(String[] args) {
17
15
new Duke ().run ();
18
16
}
19
17
20
- private void runCalendar () {
21
- System .out .println ("Enter your command: " );
22
-
23
- CalendarManager manager = new CalendarManager (new ArrayList <Event >());
24
-
25
- Scanner scanner = new Scanner (System .in );
26
- String input ;
27
- boolean isDone = false ;
28
-
29
- while (!isDone ) {
30
- input = scanner .nextLine ();
31
-
32
- if (input .equals ("end program" )) {
33
- System .out .println ("Bye bye" );
34
- break ;
35
- } else if (input .equals ("flashcard" )) {
36
- System .out .println (" Switched to flashcard functions" );
37
- runFlashcard ();
38
- } else if (manager .validCommand (input )) {
39
- manager .startCalendar (input );
40
- } else {
41
- System .out .println ("Invalid command! Enter a valid command." );
42
- }
43
- }
44
- }
45
-
46
- private void runFlashcard () {
47
- FlashcardComponent fc = new FlashcardComponent (new ArrayList <Flashcard >());
18
+ private void run () {
19
+ FlashcardComponent fc = new FlashcardComponent ();
20
+ CalendarManager cm = new CalendarManager (new ArrayList <>());
48
21
49
22
Scanner scanner = new Scanner (System .in );
50
23
String input ;
51
24
boolean shouldTerminate = false ;
52
25
53
- System .out .print ("Enter your command: " );
54
26
while (!shouldTerminate ) {
55
27
input = scanner .nextLine ();
56
28
57
- if (input .equals ("end program" )) {
58
- System .out .println ("Bye bye" );
59
- break ;
60
- } else if (input .equals ("calendar" )) {
61
- System .out .println (" Switched to calendar functions" );
62
- runCalendar ();
63
- } else if (fc .isResponsible (input )) {
29
+ if (fc .isResponsible (input )) {
64
30
fc .processInput (input );
31
+ } else if (cm .isResponsible (input )) {
32
+ cm .processInput (input );
65
33
} else {
66
- System .out .println (" Invalid command! Sorry; please try again." );
34
+ System .out .println (" Invalid command! Please try again." );
67
35
}
68
36
}
69
- }
70
37
71
- private void run () {
72
- String flashcardOrCalendar ;
73
- Scanner scanner = new Scanner (System .in );
74
-
75
- System .out .println ("Do you choose flashcard or calendar? " );
76
- flashcardOrCalendar = scanner .nextLine ();
77
-
78
- if (flashcardOrCalendar .equals ("flashcard" )) {
79
- runFlashcard ();
80
- } else if (flashcardOrCalendar .equals ("calendar" )) {
81
- runCalendar ();
82
- } else {
83
- System .out .println ("Invalid command! Sorry; please try again." );
84
- run ();
85
- }
86
38
}
87
- }
39
+ }
0 commit comments