1 00:00:01,060 --> 00:00:07,420 Let's take a look at the extraction first so we have this abstract glass of the store and it has only 2 00:00:07,420 --> 00:00:13,800 a single method for getting the color of the particular item that is being sold on the store. 3 00:00:14,200 --> 00:00:17,760 And we also have two objects that are currently sold. 4 00:00:18,010 --> 00:00:20,680 So we have a purse and we have a bag. 5 00:00:21,010 --> 00:00:24,490 Both of them have the same type of constructor. 6 00:00:24,490 --> 00:00:26,350 It accepts a color parameter. 7 00:00:26,530 --> 00:00:33,280 It will add this color parameter to their private member variables. 8 00:00:33,550 --> 00:00:37,410 And also they have the implementation for the get color method. 9 00:00:37,660 --> 00:00:45,310 So as you can see here, we do a out mentioning the color of the of the particular item and also we 10 00:00:45,310 --> 00:00:46,210 return the color. 11 00:00:46,450 --> 00:00:51,400 On the other hand, we have the color interface, an empty interface in our case just for simplicity. 12 00:00:51,790 --> 00:00:54,610 And we have two colors defined here. 13 00:00:54,610 --> 00:00:59,340 We have red, which will define only the two string method. 14 00:01:00,250 --> 00:01:06,100 So in our case, we want to output the name of the class because this is the name of the color. 15 00:01:07,150 --> 00:01:11,130 And also the same thing goes for blue as well. 16 00:01:11,350 --> 00:01:17,980 So we have the app class that will execute our code. 17 00:01:18,280 --> 00:01:22,690 So basically we created here two bags, one red and one blue. 18 00:01:22,690 --> 00:01:26,710 And you can see here we supply a new color as well. 19 00:01:27,040 --> 00:01:30,200 And two persons, one red and one blue. 20 00:01:30,880 --> 00:01:41,470 So basically all to get color methods should output the name of the color of of each item that is being 21 00:01:41,470 --> 00:01:41,940 sold. 22 00:01:42,130 --> 00:01:44,260 So let's run this. 23 00:01:47,000 --> 00:01:53,450 So as you can see, this is doing the right thing, so instead of having separate classes for red bag, 24 00:01:53,450 --> 00:02:01,070 for blue bag, you just have a single class that extends an abstract class in our case to store class. 25 00:02:01,970 --> 00:02:09,030 And it accepts as a parameter the the color of of the of each particular item. 26 00:02:09,350 --> 00:02:16,600 So it reduces very much the need for creating extra classes. 27 00:02:16,820 --> 00:02:19,810 It reduces the size of the code. 28 00:02:19,820 --> 00:02:25,020 And also it's it's very easy to read when you have such a structure. 29 00:02:26,330 --> 00:02:28,490 That's it for this tutorial. 30 00:02:29,150 --> 00:02:32,990 Join me in the next video where we are going to discuss about the filter pattern.