forked from CalebCurry/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10-consume-sdk.py
More file actions
73 lines (67 loc) · 1.95 KB
/
10-consume-sdk.py
File metadata and controls
73 lines (67 loc) · 1.95 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
def print_menu():
print("""Choose a number:
1. Print all books
2. Add a book
3. Delete a book
4. Update a book
0. QUIT""")
"""
print("Hello, Welcome to your reading list.")
while(True):
print_menu()
response = int(input())
if response == 1:
print("Here are all of your books")
elif response == 2:
print("adding a book")
elif response == 3:
print("Deleting a book")
elif response == 4:
print("Updating a book")
else:
print("Good luck reading!")
break
"""
########### CONUMSING SDK ##########
#This brought up some questions on SDK design
#Should deleting/updating a book require book object or just title? ID? So many options
#Not very easy to maintain object as you might easily do with a UI.
import booksSDK
from book import Book
print("Hello, Welcome to your reading list.")
while(True):
print_menu()
response = int(input())
if response == 1:
print("Here are all of your books:")
for book in booksSDK.get_books():
print(book)
elif response == 2:
print("Title?")
title = input()
print("Pages?")
pages = input()
booksSDK.add_book(Book(title, pages))
elif response == 3:
print("Title?")
title = input()
print("Pages?")
pages = input()
booksSDK.delete_book(Book(title, pages))
elif response == 4:
print("Current title?")
current_title = input()
print("Current pages?")
current_pages = input()
print("New title (s for same)")
new_title = input()
if str.lower(new_title) == 's':
new_title = current_title
print("New pages? (s for same)")
new_pages = input()
if str.lower(new_pages) == 's':
new_pages = current_pages
booksSDK.update_book(Book(current_title, current_pages), new_title, new_pages)
else:
print("Good luck reading!")
break