-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuse_calendar.py
More file actions
142 lines (124 loc) · 4.07 KB
/
use_calendar.py
File metadata and controls
142 lines (124 loc) · 4.07 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import Calendar as calendar
# ----------------------------------------------------------------------------
# Functions dealing with the user. This is the calendar application.
# Please do use input and print as needed in order to provide a
# nice and meaningful user interaction with your application.
# ----------------------------------------------------------------------------
def user_interface():
'''
Load calendar.txt and then interact with the user. The user interface
operates as follows, the text after command: is the command entered by the
user.
calendar loaded
command: add 2017-10-21 9 10 budget meeting
added
command: add 2017-10-22 6 7 go to the gym
added
command: add 2017-10-23 5 6 go to the gym
added
command: add 2017-11-01 15 16 Make sure to submit csc108 assignment 2
added
command: add 2017-12-02 16 17 Make sure to submit csc108 assignment 3
added
command: add 2017-11-06 8 10 Term test 2
added
command: add 2017-10-29 7 8 Get salad stuff,lettuce, red peppers, green peppers
added
command: add 2017-11-06 19 22 Sid's birthday
added
command: show
2017-12-02 :
start : 16:00,
end : 17:00,
title: Make sure to submit csc108 assignment 3
2017-11-06 :
start : 8:00,
end : 10:00,
title: Term test 2
start : 19:00,
end : 22:00,
title: Sid's birthday
2017-11-01 :
start : 15:00,
end : 16:00,
title: Make sure to submit csc108 assignment 2
2017-10-29 :
start : 7:00,
end : 8:00,
title: Get salad stuff, leuttice, red peppers, green peppers
2017-10-23 :
start : 5:00,
end : 6:00,
title: go to the gym
2017-10-22 :
start : 6:00,
end : 7:00,
title : go to the gym
2017-10-21 :
start : 9:00,
end : 10:00,
title : budget meeting
command: delete 2017-10-29 7
deleted
command: delete 2015-12-03 9
2015-12-03 is not a date in the calendar
command: delete 2017-12-02 16
deleted
command: show
2017-11-06 :
start : 8:00,
end : 10:00,
title: Term test 2
start : 19:00,
end : 22:00,
title: Sid's birthday
2017-11-01 :
start : 15:00,
end : 16:00,
title: Make sure to submit csc108 assignment 2
2017-10-23 :
start : 5:00,
end : 6:00,
title: go to the gym
2017-10-22 :
start : 6:00,
end : 7:00,
title : go to the gym
2017-10-21 :
start : 9:00,
end : 10:00,
title : budget meeting
command: quit
calendar saved
:return: None
'''
# Your code goes here
sid = calendar.load_calendar()
print("calendar loaded")
while True:
user_input = input('Command: ')
output = calendar.parse_command(user_input)
if output[0] == "error":
print(output)
elif output[0] == 'add':
prob = calendar.command_add(output[1], output[2], output[3], output[4], sid)
if prob == True:
print('added')
else:
print(prob)
elif output[0] == 'delete':
prob = calendar.command_delete(output[1], output[2], sid)
if prob == True:
print('deleted')
else:
print(prob)
elif output[0] == 'show':
print(calendar.command_show(sid))
elif output[0] == 'help':
print(calendar.command_help())
elif output[0] == "quit":
calendar.save_calendar(sid)
print("calendar saved")
break
if __name__ == "__main__":
user_interface()