E-reader Example 3
This contains multiple runs of the enhanced-ereader.py
program. User
input is bolded. The runs are interspersed with comments about how
the enhanced e-reader operates.
$ python3 enhanced_ereader.py Since this is the first time you used it, let's customize your Swindle... Please enter you name: Sedi Welcome to Sedi's Swindle v1.0! 1) Buy/See available books 2) See owned books 3) Read a book 4) Exit Choice: 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 You successfully purchased the book: Pride and Prejudice 1) Buy/See available books 2) See owned books 3) Read a book 4) Exit Choice: 2 1. Pride and Prejudice by Jane Austin (1813) 1) Buy/See available books 2) See owned books 3) Read a book 4) Exit Choice: 3 1. Pride and Prejudice by Jane Austin (1813) Which book would you like to read (0 to skip)? 1 Pride and Prejudice by Jane Austen Chapter 1 It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife. However little known the feelings or views of such a man may be on his first entering a neighbourhood, this truth is so well fixed in the minds of the surrounding families, that he is considered Showing page 0 out of 711 n (next); p (previous); q (quit): n the rightful property of some one or other of their daughters. "My dear Mr. Bennet," said his lady to him one day, "have you heard that Netherfield Park is let at last?" Mr. Bennet replied that he had not. "But it is," returned she; "for Mrs. Long has just been here, and she told me all about it." Mr. Bennet made no answer. "Do you not want to know who has taken it?" cried his wife impatiently. "You want to tell me, and I have no objection to hearing it." This was invitation enough. "Why, my dear, you must know, Mrs. Long says that Netherfield Showing page 1 out of 711 n (next); p (previous); q (quit): n is taken by a young man of large fortune from the north of England; that he came down on Monday in a chaise and four to see the place, and was so much delighted with it, that he agreed with Mr. Morris immediately; that he is to take possession before Michaelmas, and some of his servants are to be in the house by the end of next week." "What is his name?" "Bingley." "Is he married or single?" "Oh! Single, my dear, to be sure! A single man of large fortune; four or five thousand a year. What a fine thing for our girls!" "How so? How can it affect them?" "My dear Mr. Bennet," replied his wife, "how can you be so Showing page 2 out of 711 n (next); p (previous); q (quit): n tiresome! You must know that I am thinking of his marrying one of them." "Is that his design in settling here?" "Design! Nonsense, how can you talk so! But it is very likely that he may fall in love with one of them, and therefore you must visit him as soon as he comes." "I see no occasion for that. You and the girls may go, or you may send them by themselves, which perhaps will be still better, for as you are as handsome as any of them, Mr. Bingley may like you the best of the party." "My dear, you flatter me. I certainly have had my share of beauty, but I do not pretend to be anything extraordinary now. When a woman has five grown-up daughters, she ought to give over thinking of her own beauty." "In such cases, a woman has not often much beauty to think of." Showing page 3 out of 711 n (next); p (previous); q (quit): q The bookmark for Pride and Prejudice was set to page 3 1) Buy/See available books 2) See owned books 3) Read a book 4) Exit Choice: 4
Notice that when the enhanced version of the e-reader is executed again, that it remembers the owner’s name as well as all owned books (and their current bookmarks) and all of the remaining available books to buy.
$ python3 enhanced_ereader.py Welcome back Sedi! 1) Buy/See available books 2) See owned books 3) Read a book 4) Exit Choice: 3 1. Pride and Prejudice by Jane Austin (1813) Which book would you like to read (0 to skip)? 1 tiresome! You must know that I am thinking of his marrying one of them." "Is that his design in settling here?" "Design! Nonsense, how can you talk so! But it is very likely that he may fall in love with one of them, and therefore you must visit him as soon as he comes." "I see no occasion for that. You and the girls may go, or you may send them by themselves, which perhaps will be still better, for as you are as handsome as any of them, Mr. Bingley may like you the best of the party." "My dear, you flatter me. I certainly have had my share of beauty, but I do not pretend to be anything extraordinary now. When a woman has five grown-up daughters, she ought to give over thinking of her own beauty." "In such cases, a woman has not often much beauty to think of." Showing page 3 out of 711 n (next); p (previous); q (quit): n "But, my dear, you must indeed go and see Mr. Bingley when he comes into the neighbourhood." "It is more than I engage for, I assure you." "But consider your daughters. Only think what an establishment it would be for one of them. Sir William and Lady Lucas are determined to go, merely on that account, for in general, you know, they visit no newcomers. Indeed you must go, for it will be impossible for us to visit him if you do not." "You are over-scrupulous, surely. I dare say Mr. Bingley will be very glad to see you; and I will send a few lines by you to assure him of my hearty consent to his marrying whichever he chooses of the girls; though I must throw in a good word for my little Lizzy." "I desire you will do no such thing. Lizzy is not a bit better than the others; and I am sure she is not half so handsome as Showing page 4 out of 711 n (next); p (previous); q (quit): q The bookmark for Pride and Prejudice was set to page 4 1) Buy/See available books 2) See owned books 3) Read a book 4) Exit Choice: 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. 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)? 3 You successfully purchased the book: Peter Pan 1) Buy/See available books 2) See owned books 3) Read a book 4) Exit Choice: 2 1. Pride and Prejudice by Jane Austin (1813) 2. Peter Pan by J. M. Barrie (1922) 1) Buy/See available books 2) See owned books 3) Read a book 4) Exit Choice: 4
In the user’s last interaction with the e-reader they bought a second book and the enhanced e-reader maintains this information.
$ python3 enhanced_ereader.py Welcome back Sedi! 1) Buy/See available books 2) See owned books 3) Read a book 4) Exit Choice: 2 1. Pride and Prejudice by Jane Austin (1813) 2. Peter Pan by J. M. Barrie (1922) 1) Buy/See available books 2) See owned books 3) Read a book 4) Exit Choice: 3 1. Pride and Prejudice by Jane Austin (1813) 2. Peter Pan by J. M. Barrie (1922) Which book would you like to read (0 to skip)? 2 Chapter 1 PETER BREAKS THROUGH All children, except one, grow up. They soon know that they will grow up, and the way Wendy knew was this. One day when she was two years old she was playing in a garden, and she plucked another flower and ran with it to her mother. I suppose she must have looked rather delightful, for Mrs. Darling put her hand to her heart and cried, "Oh, why can't you remain like this for ever!" This was all that passed between them on the subject, but henceforth Wendy knew that she must grow up. You always know after you are two. Two is the beginning of the end. Of course they lived at 14 [their house number on their street], and until Wendy came her mother was the chief one. She was a lovely lady, with a romantic mind and such a sweet mocking mouth. Her romantic mind was like the tiny boxes, one within the other, that come from the puzzling East, however many you discover there is always one more; and her sweet mocking mouth had one kiss on it that Wendy could never get, though there it was, perfectly conspicuous in the right-hand corner. The way Mr. Darling won her was this: the many gentlemen who had been Showing page 0 out of 308 n (next); p (previous); q (quit): n boys when she was a girl discovered simultaneously that they loved her, and they all ran to her house to propose to her except Mr. Darling, who took a cab and nipped in first, and so he got her. He got all of her, except the innermost box and the kiss. He never knew about the box, and in time he gave up trying for the kiss. Wendy thought Napoleon could have got it, but I can picture him trying, and then going off in a passion, slamming the door. Mr. Darling used to boast to Wendy that her mother not only loved him but respected him. He was one of those deep ones who know about stocks and shares. Of course no one really knows, but he quite seemed to know, and he often said stocks were up and shares were down in a way that would have made any woman respect him. Mrs. Darling was married in white, and at first she kept the books perfectly, almost gleefully, as if it were a game, not so much as a Brussels sprout was missing; but by and by whole cauliflowers dropped out, and instead of them there were pictures of babies without faces. She drew them when she should have been totting up. They were Mrs. Darling's guesses. Showing page 1 out of 308 n (next); p (previous); q (quit): q The bookmark for Peter Pan was set to page 1 1) Buy/See available books 2) See owned books 3) Read a book 4) Exit Choice: 4