1 00:00:00,600 --> 00:00:04,570 So when we last left off we had just created this inventoryable module, and 2 00:00:04,570 --> 00:00:08,550 we're going to use that in all of our different product classes. 3 00:00:09,910 --> 00:00:14,940 So let's go ahead and first off we're just going to include it 4 00:00:14,940 --> 00:00:18,690 in the shirt class, and that'll be a good start. 5 00:00:20,610 --> 00:00:25,440 So now, let's go ahead and make a couple of attribute methods for 6 00:00:25,440 --> 00:00:28,720 setting the stock status of an item. 7 00:00:28,720 --> 00:00:32,830 So we want to be able to say, okay this is how many 8 00:00:34,370 --> 00:00:39,650 units are in stock for a shirt, a pair of pants, an accessory, whatever. 9 00:00:41,428 --> 00:00:48,060 Now we're gonna define this method called stock_count, 10 00:00:48,060 --> 00:00:53,100 and stock count is going to work very similarly to our 11 00:00:53,100 --> 00:01:00,860 instances class method that we used over in the extend tracking module. 12 00:01:00,860 --> 00:01:03,542 So we're just going to conditionally set it to zero. 13 00:01:07,002 --> 00:01:12,206 Now what this is going to do is initialize a variable called stock_count, 14 00:01:12,206 --> 00:01:15,880 and set it to zero if it does not already exist. 15 00:01:15,880 --> 00:01:19,110 If it does exist, the variable will be returned. 16 00:01:20,410 --> 00:01:24,090 Now because we've done that we also need something to set the stock count. 17 00:01:25,710 --> 00:01:29,440 So we define a method called stock_count=(number), and 18 00:01:31,560 --> 00:01:35,730 then we'll just say the stock count now equals the number not zero. 19 00:01:38,780 --> 00:01:41,860 So let's go ahead and test this out really quickly. 20 00:01:41,860 --> 00:01:46,538 We'll say shirt1.stock_count = 10. 21 00:01:46,538 --> 00:01:48,612 Now we can print these both out. 22 00:01:54,852 --> 00:02:00,330 And we'll say shirt1.stock_count, and we're going to copy and 23 00:02:00,330 --> 00:02:05,146 paste that line and we're going to say Shirt 2 stock count, 24 00:02:05,146 --> 00:02:08,650 and we should see ten and zero if we run this. 25 00:02:12,310 --> 00:02:16,050 And we do, and that's exactly what we want. 26 00:02:16,050 --> 00:02:20,670 So when we put a new item in the inventory, if we don't explicitly 27 00:02:20,670 --> 00:02:24,920 set the stock count we're going to think that we have zero in stock. 28 00:02:24,920 --> 00:02:25,820 And this makes sense. 29 00:02:28,160 --> 00:02:32,300 So now let's go ahead and write another method to see whether or 30 00:02:32,300 --> 00:02:34,110 not something is in stock. 31 00:02:37,460 --> 00:02:43,440 And we're going to say it's in stock if the stock count is greater than zero. 32 00:02:46,180 --> 00:02:49,477 And we don't need to replay these, but we'll go ahead and 33 00:02:49,477 --> 00:02:51,102 just say shirt one in stock. 34 00:02:57,044 --> 00:02:58,644 And the same thing for Shirt 2. 35 00:03:08,144 --> 00:03:10,522 And that looks pretty good.