Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Introducing the Project4:59 with Craig Dennis
Wait until you meet Tex and hear all about his whacky ideas.
So I've got a really exciting project for us to work on. 0:00 I was on an airplane, chatting with my seatmate, you know, as you do. 0:04 He was a Texan, and not surprisingly, he goes by the nickname of Tex. 0:08 He had one of those accents, one of those hats. 0:13 >> He was like the real deal. 0:15 And he told me he had made a huge investment in vending machines. 0:17 And it started out small. 0:21 He had a few snack machines at an office and 0:22 a couple of soda machines at a college campus. 0:25 But soon with all his return on investment he was able to take his profits and 0:27 buy more. 0:31 And now he had machines all over the US and 0:32 is starting to get someplace internationally. 0:35 When he asked what I did, I told him I was a developer and a teacher, and he said. 0:38 >> Well I got an idea, why don't y'all fix my problems as an exercise then? 0:43 >> I'm always looking for new adventures for us, so 0:48 I figured to quote the thought leader, Chockers, sure, why not? 0:50 I had him talk about the problem space, and here's what he said. 0:55 >> So let me tell you what I love. 0:58 Some of these more newfangled machines I got, 1:00 they tell me exactly how much money I got in them and how much inventory I got left. 1:03 I love it. 1:08 [NOISE] I can plan and send in my people to gather when the time is right. 1:09 Problem is, sonny, I got in this game earlier, and my old machines, 1:13 my legacy ones, I guess you'd call them, they don't tell me nothing. 1:16 I have to pay to have people go collect and check that it's not empty. 1:21 It's not very cost effective. 1:26 Now, If I could do something about that, 1:28 I'd reckon I'd be as happy as a hog in mud. 1:30 >> Well friends, I think we have a chance to make this man very happy. 1:34 And it seems like a really promising business opportunity. 1:38 You're more than capable of nabbing this one. 1:41 I chatted with him some more about the specifications and 1:44 I jotted them down on one of these tiny napkins that they give you on your 1:47 tiny table that you can use when you sit in your tiny seat. 1:51 I wrote this pretty tiny, but this is what I captured. 1:54 Not all vending machines are created equal. 1:58 Now it's important to remember that these older machines vend different things, 2:01 they also have different ways of working. 2:06 By different I mean this, 2:09 the way you interact with the machine is a little bit different. 2:10 All the machines accept change, some accept bills and even credit cards. 2:14 The newfangled ones that Tex was talking about were actually able to use 2:19 Apple Pay and Google Wallet. 2:23 The way you choose your product is different too. 2:25 Some have a grouping of buttons, you know the kind where you punch in a letter and 2:28 then a number to determine the row and column. 2:32 Then there are those others that were just the flavor of the soda, 2:35 there are similarities though. 2:39 All machines store the physical products in a similar way. 2:41 Every single machine that this guy owns stores the items in rows and columns. 2:45 And each bin, that's what they call the container that holds all the specific 2:50 items until they're purchased. 2:54 Well they can hold a set maximum number of items. 2:56 They always work FIFO, and that's first in first out. 2:59 That way things don't get stale. 3:03 No one wants a stale Twinkie. 3:04 So, first things first, let's noodle a bit on what sort of data structure 3:06 would work to maintain our rows and columns of bins. 3:10 Hm, it's sort of like a spreadsheet, right? 3:13 Rows and columns, they line up to a single value. 3:16 A very common way to build a grid like that is to use what is 3:19 known as a multi-dimensional array. 3:23 Now, these are a little hard to conceptualize at first and 3:25 they definitely have a science fiction sounding name. 3:28 So let's walk through one real quick and make it seem more earthly. 3:31 So an array is just a list of values, right? 3:36 We could have and array of fruit like this one here, and 3:38 we can access each value by index. 3:42 Remember it's zero based. 3:45 So, ready? 3:47 A two-dimensional ray is just an array of arrays. 3:48 Each array can be thought of as a row. 3:53 So, let's make a two by three grid. 3:56 That is, it will be two rows of three items. 3:58 Just like this. 4:00 See, each item here is a row, or three item array. 4:02 So, you can access an apple just like you would imagine. 4:06 Apple, the first zero is the row index. 4:10 The second is the column. 4:12 And what would this be? 4:14 So, let's take a look. 4:17 The first one there is the second row, right? 4:18 And then we get the item at index 2. 4:20 So they third item here which is fig. 4:23 All right, got it? 4:26 Now that should work for mapping out our rows and columns of the machine. 4:28 We still need something for our bins. 4:32 Remember, that's the thing where you place the items. 4:34 So each one of those locations should hold a bin, which is also a dimension, right? 4:37 It has a bunch of items, 3-D. 4:43 Bins usually have a corkscrew-like system that spins and 4:45 it drops the delicious treat. 4:49 I feel like we went over a data structure like this, didn't we? 4:51 Do you remember? 4:54 Well let's take a quick break and 4:55 practice some of this stuff and maybe it'll come back to us. 4:57
You need to sign up for Treehouse in order to download course files.Sign up