Skip to content

Commit 98b52cf

Browse files
committed
Work with SDK
1 parent e75605e commit 98b52cf

1 file changed

Lines changed: 50 additions & 1 deletion

File tree

‎python/10-sql/consume-sdk.py‎

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ def print_menu():
44
2. Add a book
55
3. Delete a book
66
4. Update a book
7-
Q. QUIT""")
7+
0. QUIT""")
88

9+
"""
910
print("Hello, Welcome to your reading list.")
1011
while(True):
1112
print_menu()
@@ -21,5 +22,53 @@ def print_menu():
2122
else:
2223
print("Good luck reading!")
2324
break
25+
"""
2426

27+
########### CONUMSING SDK ##########
2528

29+
30+
31+
#This brought up some questions on SDK design
32+
#Should deleting/updating a book require book object or just title? ID? So many options
33+
#Not very easy to maintain object as you might easily do with a UI.
34+
35+
import booksSDK
36+
from book import Book
37+
38+
print("Hello, Welcome to your reading list.")
39+
while(True):
40+
print_menu()
41+
response = int(input())
42+
if response == 1:
43+
print("Here are all of your books:")
44+
for book in booksSDK.get_books():
45+
print(book)
46+
elif response == 2:
47+
print("Title?")
48+
title = input()
49+
print("Pages?")
50+
pages = input()
51+
booksSDK.add_book(Book(title, pages))
52+
elif response == 3:
53+
print("Title?")
54+
title = input()
55+
print("Pages?")
56+
pages = input()
57+
booksSDK.delete_book(Book(title, pages))
58+
elif response == 4:
59+
print("Current title?")
60+
current_title = input()
61+
print("Current pages?")
62+
current_pages = input()
63+
print("New title (s for same)")
64+
new_title = input()
65+
if str.lower(new_title) == 's':
66+
new_title = current_title
67+
print("New pages? (s for same)")
68+
new_pages = input()
69+
if str.lower(new_pages) == 's':
70+
new_pages = current_pages
71+
booksSDK.update_book(Book(current_title, current_pages), new_title, new_pages)
72+
else:
73+
print("Good luck reading!")
74+
break

0 commit comments

Comments
 (0)