E-reader Example 4
Below is a single run of the ereader.py program, showing various edge cases,
including when the user chooses the "read" option when no books are owned, the
"buy" option when no books are available, and entering invalid numbers when
selecting a book to read or buy.
$ python3 ereader.py Since this is the first time you used it, let's customize your Swindle... Please enter your name: Nathan Welcome to Nathan's Swindle v1.0! -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 3 You don't own any books. -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 1 1. Alice in Wonderland by Lewis Carroll (1865) 2. Mary Had a Little Lamb by Sarah Josepha Hale (1830) 3. Peter Pan by J. M. Barrie (1922) 4. Pride and Prejudice by Jane Austin (1813) 5. Romeo and Juliet by William Shakespeare (1597) 6. The Time Machine by H. G. Wells (1895) 7. Treasure Island by Robert Louis Stevenson (1883) 8. Ulysses by James Joyce (1922) Which book would you like to buy (0 to skip)? -4 Sorry, that's not a valid choice. Please enter a valid option. Which book would you like to buy (0 to skip)? 10 Sorry, that's not a valid choice. Please enter a valid option. Which book would you like to buy (0 to skip)? 1 You successfully purchased the book: Alice in Wonderland -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 1 1. Mary Had a Little Lamb by Sarah Josepha Hale (1830) 2. Peter Pan by J. M. Barrie (1922) 3. Pride and Prejudice by Jane Austin (1813) 4. Romeo and Juliet by William Shakespeare (1597) 5. The Time Machine by H. G. Wells (1895) 6. Treasure Island by Robert Louis Stevenson (1883) 7. Ulysses by James Joyce (1922) Which book would you like to buy (0 to skip)? 5 You successfully purchased the book: The Time Machine -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 1 1. Mary Had a Little Lamb by Sarah Josepha Hale (1830) 2. Peter Pan by J. M. Barrie (1922) 3. Pride and Prejudice by Jane Austin (1813) 4. Romeo and Juliet by William Shakespeare (1597) 5. Treasure Island by Robert Louis Stevenson (1883) 6. Ulysses by James Joyce (1922) Which book would you like to buy (0 to skip)? 2 You successfully purchased the book: Peter Pan -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 1 1. Mary Had a Little Lamb by Sarah Josepha Hale (1830) 2. Pride and Prejudice by Jane Austin (1813) 3. Romeo and Juliet by William Shakespeare (1597) 4. Treasure Island by Robert Louis Stevenson (1883) 5. Ulysses by James Joyce (1922) Which book would you like to buy (0 to skip)? 2 You successfully purchased the book: Pride and Prejudice -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 1 1. Mary Had a Little Lamb by Sarah Josepha Hale (1830) 2. Romeo and Juliet by William Shakespeare (1597) 3. Treasure Island by Robert Louis Stevenson (1883) 4. Ulysses by James Joyce (1922) Which book would you like to buy (0 to skip)? 3 You successfully purchased the book: Treasure Island -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 1 1. Mary Had a Little Lamb by Sarah Josepha Hale (1830) 2. Romeo and Juliet by William Shakespeare (1597) 3. Ulysses by James Joyce (1922) Which book would you like to buy (0 to skip)? 2 You successfully purchased the book: Romeo and Juliet -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 1 1. Mary Had a Little Lamb by Sarah Josepha Hale (1830) 2. Ulysses by James Joyce (1922) Which book would you like to buy (0 to skip)? 2 You successfully purchased the book: Ulysses -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 1 1. Mary Had a Little Lamb by Sarah Josepha Hale (1830) Which book would you like to buy (0 to skip)? 1 You successfully purchased the book: Mary Had a Little Lamb -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 1 There are no books available. -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 2 1. Alice in Wonderland by Lewis Carroll (1865) 2. The Time Machine by H. G. Wells (1895) 3. Peter Pan by J. M. Barrie (1922) 4. Pride and Prejudice by Jane Austin (1813) 5. Treasure Island by Robert Louis Stevenson (1883) 6. Romeo and Juliet by William Shakespeare (1597) 7. Ulysses by James Joyce (1922) 8. Mary Had a Little Lamb by Sarah Josepha Hale (1830) -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 3 1. Alice in Wonderland by Lewis Carroll (1865) 2. The Time Machine by H. G. Wells (1895) 3. Peter Pan by J. M. Barrie (1922) 4. Pride and Prejudice by Jane Austin (1813) 5. Treasure Island by Robert Louis Stevenson (1883) 6. Romeo and Juliet by William Shakespeare (1597) 7. Ulysses by James Joyce (1922) 8. Mary Had a Little Lamb by Sarah Josepha Hale (1830) Which book would you like to read (0 to skip)? -2 Sorry, that's not a valid choice. Which book would you like to read (0 to skip)? 100 Sorry, that's not a valid choice. Which book would you like to read (0 to skip)? 0 -------------------------------------------------- 1) Buy/See available books 2) See owned books 3) Read a book 0) Exit Enter a selection: 4