-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMyCalendarTester.java
More file actions
101 lines (91 loc) · 3.85 KB
/
MyCalendarTester.java
File metadata and controls
101 lines (91 loc) · 3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import java.util.GregorianCalendar;
import java.util.Scanner;
import java.util.Collections;
import java.util.Set;
import java.util.TreeSet;
/**
* The intent of this class is to test the functionality of the Calendar program.
* @author Ashraf Saber
* Version: 1
*/
public class MyCalendarTester {
/**
* Main function to test the Calendar Program
*/
public static void main(String[] args){
// Creating a calendar object myCalendar
CalendarClass myCalendar = new CalendarClass();
// Creating a scanner object inputScanner to read user input
Scanner inputScanner = new Scanner(System.in);
// Declaring object of type String for userInput
String userInput;
// Creating a GregorianCalendar object calendar
GregorianCalendar calendar = new GregorianCalendar();
// Printing the Calendar month view
myCalendar.printMonth(calendar);
// Creating a do-While loop to provide the user with the required navigation options
do{
System.out.println("Select one of the following options: ");
System.out.println("[L]oad [V]iew by [C]reate, [G]o to [E]vent list [D]elete [Q]uit");
userInput = inputScanner.nextLine().toUpperCase();
switch(userInput){
case "L": System.out.println(" ");
myCalendar.load();
break;
case "V": System.out.println("[D]ay view or [M]view ? ");
String viewInput = inputScanner.nextLine();
if(viewInput.equals("D")|| viewInput.equals("d")){
String dNavigation;
myCalendar.printDay(calendar);
do{
System.out.println("[P]revious or [N]ext or [M]ain menu ?");
dNavigation = inputScanner.nextLine();
if(dNavigation.equals("P")||dNavigation.equals("p")){myCalendar.previousDay(calendar);}
else if(dNavigation.equals("N")||dNavigation.equals("n")){myCalendar.nextDay(calendar);}
} while(! (dNavigation.equals("M") || dNavigation.equals("m")));
}else if(viewInput.equals("M") ||viewInput.equals("m")){
myCalendar.printMonth(calendar);
String mNavigation;
do{
System.out.println("[P]revious or [N]ext or [M]ain menu ?");
mNavigation = inputScanner.nextLine();
if(mNavigation.equals("P")||mNavigation.equals("p")){ myCalendar.previousMonth(calendar); }
else if(mNavigation.equals("N")||mNavigation.equals("n")){myCalendar.nextMonth(calendar);}
} while(! (mNavigation.equals("M") || mNavigation.equals("m")));
}
break;
case "C":
System.out.println("\nTitle: ");
String titleInput = inputScanner.nextLine();
System.out.println("\nDate: ");
String dateInput = inputScanner.nextLine();
System.out.println("\nStart Time (24:00 format):");
String startTInput = inputScanner.nextLine();
System.out.println("\nEnd Time (24:00 format): ");
String endTInput = inputScanner.nextLine();
if((endTInput.length()==0 || endTInput==null)){endTInput="23:59";}
myCalendar.createEvent(titleInput, dateInput, startTInput, endTInput);
break;
case "G": System.out.println("\nPlease enter date (MM/DD/YYYY): ");
String goToInput = inputScanner.nextLine();
System.out.print("\n");
myCalendar.printDay(myCalendar.stringToGC(goToInput));
break;
case "E": System.out.println(" ");
myCalendar.printAllEvents();
System.out.println(" ");
break;
case "D": System.out.println("[S]elected or [A]ll ? ");
String deleteInput = inputScanner.nextLine();
if(deleteInput.equals("s") || deleteInput.equals("S") ){
System.out.println("\nPlease enter date (MM/DD/YYYY):");
String dateDInput = inputScanner.nextLine();
myCalendar.deleteSelected(dateDInput);
}else if(deleteInput.equals("A")||deleteInput.equals("a"))
myCalendar.deleteAll();
break;
}
}while(!userInput.equals("Q"));
myCalendar.quit();
}
}