1 00:00:00,700 --> 00:00:05,840 Okay, so looking at these, why don't we go ahead and grab this one first? 2 00:00:05,840 --> 00:00:08,820 So as the user, I should be able to confirm my order so 3 00:00:08,820 --> 00:00:12,500 that I do not accidentally purchase more tickets than intended. 4 00:00:12,500 --> 00:00:16,700 And I wanna do that one because I know that that's right after what we just did. 5 00:00:16,700 --> 00:00:19,360 We just showed them the price, so let's prompt and 6 00:00:19,360 --> 00:00:22,725 see If they want to buy them, let's do it. 7 00:00:22,725 --> 00:00:25,000 So put that In Progress. 8 00:00:25,000 --> 00:00:26,610 Let's flip over here. 9 00:00:26,610 --> 00:00:28,030 So we just showed the total due. 10 00:00:28,030 --> 00:00:33,350 So let's come in here and let's ask if they want to continue, all right? 11 00:00:33,350 --> 00:00:41,054 So we'll say Prompt user if they want to proceed. 12 00:00:41,054 --> 00:00:45,998 And typically the way that you do that in these console applications is you 13 00:00:45,998 --> 00:00:48,561 ask them for a Y or an N, for a yes or no. 14 00:00:48,561 --> 00:00:54,968 So we can do that, and then if they answer that they do wanna proceed, 15 00:00:54,968 --> 00:01:00,720 so If they want to proceed, we got a couple of things, right? 16 00:01:00,720 --> 00:01:02,810 So we need to branch out on that decision. 17 00:01:02,810 --> 00:01:04,960 So let's, how are we gonna mark this? 18 00:01:04,960 --> 00:01:05,510 Let's do it this way. 19 00:01:05,510 --> 00:01:07,080 I'll do this on separate lines. 20 00:01:07,080 --> 00:01:11,570 So if they want to proceed, we're going to print out to the screen. 21 00:01:12,880 --> 00:01:16,070 Let's just print out SOLD!, so that we can confirm the purchase cuz 22 00:01:16,070 --> 00:01:18,110 remember we're not gonna process the credit card. 23 00:01:18,110 --> 00:01:19,600 So we'll say to confirm purchase. 24 00:01:22,000 --> 00:01:26,720 And because they did purchase it, we need to decrement, or 25 00:01:26,720 --> 00:01:30,260 reduce by the number of tickets that they actually bought, right. 26 00:01:30,260 --> 00:01:32,834 So let's see. 27 00:01:32,834 --> 00:01:36,388 And then decrement, or reduce by, 28 00:01:36,388 --> 00:01:42,230 the tickets remaining, 29 00:01:42,230 --> 00:01:45,890 by the number of tickets purchased. 30 00:01:48,050 --> 00:01:50,980 Cool, so that's if it did work. 31 00:01:50,980 --> 00:01:53,426 So, lets do that, we'll give you separate line there. 32 00:01:53,426 --> 00:01:56,794 And then, of course, we'll have our Otherwise. 33 00:01:59,419 --> 00:02:01,490 So, they wanna keep it friendly, right? 34 00:02:01,490 --> 00:02:06,200 So, let's just go ahead and otherwise let's thank them by name, 35 00:02:06,200 --> 00:02:08,336 that sounds good. 36 00:02:08,336 --> 00:02:09,375 All right, so 37 00:02:09,375 --> 00:02:15,880 it sounds like some branching logic based on their decision of Y or N, you got it? 38 00:02:15,880 --> 00:02:18,570 Now go ahead and take these line by line, you got this. 39 00:02:18,570 --> 00:02:21,640 Check the teacher's notes and use the forum if you get stuck. 40 00:02:21,640 --> 00:02:22,400 Ready? 41 00:02:22,400 --> 00:02:23,860 Pause me. 42 00:02:23,860 --> 00:02:25,160 Okay, all set? 43 00:02:25,160 --> 00:02:28,830 So here's what I did, I prompted again and I was using input and 44 00:02:28,830 --> 00:02:33,145 I stored that in a variable called should proceed pretty clear right? 45 00:02:33,145 --> 00:02:38,960 input ("Do you want to proceed? 46 00:02:38,960 --> 00:02:41,940 And I gave them a Y/N and just wrote it there. 47 00:02:41,940 --> 00:02:43,196 Give a couple of spaces. 48 00:02:45,196 --> 00:02:48,560 And so that will come up and they'll say yes or no. 49 00:02:48,560 --> 00:02:53,030 And so if they want to proceed, so if should_proceed. 50 00:02:53,030 --> 00:02:54,640 Now something I did here. 51 00:02:54,640 --> 00:02:58,240 As I made, I'm checking the lowercase version of should proceed. 52 00:02:58,240 --> 00:03:00,690 Just in case they entered a lowercase y or a capital y. 53 00:03:00,690 --> 00:03:06,590 Either one, if either one of those is y, right, lower. 54 00:03:06,590 --> 00:03:11,931 So, if y is equal to y, we're gonna open up that body and 55 00:03:11,931 --> 00:03:16,377 we're gonna print that to the screen SOLD!. 56 00:03:16,377 --> 00:03:20,684 And it looks like we are indented too far here, aren't we? 57 00:03:20,684 --> 00:03:22,390 Let's go ahead and bring this back. 58 00:03:23,770 --> 00:03:25,210 Staring to feel a little awkward there. 59 00:03:27,060 --> 00:03:29,560 There we go. So we're gonna print sold, 60 00:03:29,560 --> 00:03:33,140 and then we're gonna decrement the tickets remaining. 61 00:03:33,140 --> 00:03:34,170 And you know what I'm gonna do? 62 00:03:34,170 --> 00:03:36,360 I'm gonna add a reminder here for us. 63 00:03:36,360 --> 00:03:38,682 I'm gonna put in a TODO. 64 00:03:38,682 --> 00:03:41,651 Spanish speakers sometimes think that that means all. 65 00:03:41,651 --> 00:03:46,927 I've had worked with a few native Spanish speakers and to do they think it's 66 00:03:46,927 --> 00:03:51,875 like to-do, like all, it means to do like we're gonna do this later, 67 00:03:51,875 --> 00:03:56,340 so we're gonna gather credit card information and process it. 68 00:03:57,750 --> 00:03:58,560 Awesome. 69 00:03:58,560 --> 00:04:02,010 And that's already on the Trello board, we won't commit to completing it just yet, 70 00:04:02,010 --> 00:04:06,480 but I'm gonna leave this here so next time we come into the code we know it's there. 71 00:04:06,480 --> 00:04:09,510 And now I'm gonna use in place subtraction on tickets remaining, 72 00:04:09,510 --> 00:04:13,093 just like we've done in place addition, you can also do it with subtraction. 73 00:04:13,093 --> 00:04:19,636 So tickets_remaining -= num_tickets, right. 74 00:04:19,636 --> 00:04:24,981 So, that's shorthand for tickets remaining = tickets remaining- num_tickets. 75 00:04:24,981 --> 00:04:27,442 Just using that -= for in place subtraction. 76 00:04:27,442 --> 00:04:31,590 And so this Otherwise, this is an else clause here, right? 77 00:04:31,590 --> 00:04:39,171 So else, we're gonna print, otherwise were gonna thank them by name, 78 00:04:39,171 --> 00:04:44,820 and we'll print, well, Thank you anyways. 79 00:04:44,820 --> 00:04:48,190 Placeholder, and we'll format that. 80 00:04:48,190 --> 00:04:50,570 Pass on that name, close that up. 81 00:04:51,680 --> 00:04:54,280 Okay, I'm gonna save this, and give it a run, 82 00:04:54,280 --> 00:04:56,635 let's see what mine looks like right now. 83 00:04:56,635 --> 00:04:57,526 How do you do? 84 00:05:00,139 --> 00:05:01,740 There are a hundred tickets remaining. 85 00:05:01,740 --> 00:05:02,540 What is your name? 86 00:05:02,540 --> 00:05:05,220 My name is Craig, I would like to have 3 tickets. 87 00:05:05,220 --> 00:05:09,080 The total due is $30, do you wanna proceed? 88 00:05:09,080 --> 00:05:10,270 No way. 89 00:05:10,270 --> 00:05:11,780 So it's not Y, right? 90 00:05:11,780 --> 00:05:12,690 So it says thank you anyway. 91 00:05:12,690 --> 00:05:13,640 So let's do the other one. 92 00:05:13,640 --> 00:05:18,290 My name is Craig, Crag, sure, and 93 00:05:18,290 --> 00:05:22,110 I wanna buy four tickets, and do you wanna proceed? 94 00:05:22,110 --> 00:05:25,860 Yes as a matter of fact I do but I lower case y, want to proceed. 95 00:05:25,860 --> 00:05:26,682 Sold. 96 00:05:26,682 --> 00:05:30,278 So I don't actually know if that decrementing the tickets remaining 97 00:05:30,278 --> 00:05:33,821 actually worked but I think maybe another ticket will get us there. 98 00:05:33,821 --> 00:05:38,660 So, let's flip back to the Trello board real quick. 99 00:05:38,660 --> 00:05:39,990 Let's look over there. 100 00:05:39,990 --> 00:05:41,720 I think we're done with this confirmation one. 101 00:05:41,720 --> 00:05:42,586 Nice job. 102 00:05:43,699 --> 00:05:44,823 Okay, so as a user, 103 00:05:44,823 --> 00:05:48,410 I should not be offered tickets if there aren't any available. 104 00:05:48,410 --> 00:05:50,960 Let's move that over to In Progress. 105 00:05:50,960 --> 00:05:52,140 Awesome, and let's flip back. 106 00:05:53,920 --> 00:05:55,762 So, I think we can tackle this one but 107 00:05:55,762 --> 00:05:59,910 we're going to need to assume that there's some sort of continuum, right? 108 00:05:59,910 --> 00:06:03,670 This code will continue to run until there aren't any tickets left. 109 00:06:03,670 --> 00:06:08,370 So, let's see, we want all of this code, right? 110 00:06:08,370 --> 00:06:12,010 We want all of this code that we wrote, like from hereon down. 111 00:06:12,010 --> 00:06:13,951 We want that to go, right? 112 00:06:13,951 --> 00:06:18,808 Makes sense, so we want to run this code 113 00:06:18,808 --> 00:06:24,118 continuously until we run out of tickets. 114 00:06:24,118 --> 00:06:27,252 Makes sense, so this just keeps on prompting, keeps on saying that stuff. 115 00:06:27,252 --> 00:06:31,724 And then at the very end we need to let them know when they sell out, so 116 00:06:31,724 --> 00:06:34,475 let's just scroll all the way down here. 117 00:06:34,475 --> 00:06:36,788 Look at this, we're at 38 lines right now. 118 00:06:36,788 --> 00:06:40,879 So, we are going to, here we are gonna notify 119 00:06:40,879 --> 00:06:46,230 the user that the tickets are sold out, of course. 120 00:06:46,230 --> 00:06:51,096 After they are sold out, after the continuum has happened. 121 00:06:51,096 --> 00:06:54,960 So one thing before I let you go, I wanna show you this cuz it seems fair. 122 00:06:54,960 --> 00:06:59,893 If you highlight this you can go ahead and you can do an Edit, and you can Indent. 123 00:06:59,893 --> 00:07:03,690 And you'll see here on my Mac, it's command and then right bracket. 124 00:07:03,690 --> 00:07:07,470 So if you highlight some code, you can do a command bracket or left 125 00:07:07,470 --> 00:07:11,640 bracket to go in and out to indent, that helps when you wanna move a block over. 126 00:07:13,530 --> 00:07:15,662 So you've got this, right? 127 00:07:15,662 --> 00:07:19,970 You wanna run this code while there are still some tickets left. 128 00:07:19,970 --> 00:07:21,480 And then at the very bottom, 129 00:07:21,480 --> 00:07:25,280 you want to print Sold Out when there aren't tickets available anymore. 130 00:07:25,280 --> 00:07:26,018 You got this. 131 00:07:26,018 --> 00:07:26,799 Ready? 132 00:07:26,799 --> 00:07:27,889 Pause me. 133 00:07:29,610 --> 00:07:32,310 Okay, so, here's how I did it. 134 00:07:32,310 --> 00:07:35,341 So while there are tickets remaining. 135 00:07:38,155 --> 00:07:40,860 And then I went all the way down to the bottom. 136 00:07:40,860 --> 00:07:44,461 I held down a Shift and went all the way down to the bottom here. 137 00:07:46,729 --> 00:07:51,328 And then I went ahead and indented that. 138 00:07:51,328 --> 00:07:56,823 And down here we're just gonna say print("Sorry 139 00:07:56,823 --> 00:08:00,537 the tickets are all sold out!!! 140 00:08:00,537 --> 00:08:04,810 I'm gonna make an emoji sad face, because that seems aprops. 141 00:08:04,810 --> 00:08:07,870 Now, note, I used the truthiness of tickets remaining. 142 00:08:08,960 --> 00:08:11,640 When this gets down to zero, it will be false. 143 00:08:11,640 --> 00:08:14,860 Remember, any number other thanzero is true. 144 00:08:14,860 --> 00:08:18,060 You know what though, since I just had to explain that to you, 145 00:08:18,060 --> 00:08:20,510 maybe I should be more explicit. 146 00:08:20,510 --> 00:08:24,980 So let's do that, tickets remaining are greater than or equal to one, 147 00:08:26,320 --> 00:08:30,760 we will run this code and then we will notify them when they're sold out. 148 00:08:32,280 --> 00:08:34,880 Okay, let's see how we did. 149 00:08:37,820 --> 00:08:39,630 We'll say python masterticket. 150 00:08:40,980 --> 00:08:41,650 What is your name? 151 00:08:41,650 --> 00:08:45,410 My name is John and I would like to have 98 tickets please. 152 00:08:45,410 --> 00:08:48,480 Total due is 980, that seems reasonable, let's do it. 153 00:08:49,650 --> 00:08:51,210 There's 2 tickets left. 154 00:08:51,210 --> 00:08:52,460 So now Terry comes in. 155 00:08:53,500 --> 00:08:54,890 He buys 2. 156 00:08:54,890 --> 00:08:57,300 Total due is 20, Terry wants it. 157 00:08:58,520 --> 00:09:00,920 Sold, and now the tickets are all sold out. 158 00:09:00,920 --> 00:09:02,000 Boom. 159 00:09:02,000 --> 00:09:03,390 Nice job. 160 00:09:03,390 --> 00:09:05,280 No more offering of tickets. 161 00:09:05,280 --> 00:09:06,460 All right, so let's move this over. 162 00:09:06,460 --> 00:09:08,110 This is done-zo. 163 00:09:08,110 --> 00:09:09,190 Feels so good doesn't it? 164 00:09:09,190 --> 00:09:10,630 Making something done. 165 00:09:10,630 --> 00:09:12,180 So, how'd you do? 166 00:09:12,180 --> 00:09:15,125 If you had any problems, remember to ask in the community, 167 00:09:15,125 --> 00:09:18,270 if anything at all isn't clear, we'll get it sorted out. 168 00:09:18,270 --> 00:09:22,570 Okay, we'll tackle those user friendly errors next. 169 00:09:22,570 --> 00:09:24,539 It's our last ticket, I'm gonna move it to In Progress.