1 00:00:00,600 --> 00:00:01,410 ‫Welcome back. 2 00:00:01,440 --> 00:00:03,510 ‫In this video, it's all about inheritance. 3 00:00:03,510 --> 00:00:09,510 ‫And we're going to go ahead and create a class, which I'm just going to call post. 4 00:00:09,510 --> 00:00:13,500 ‫So a new class and it's going to be a post. 5 00:00:13,500 --> 00:00:20,490 ‫So imagine that being a social media post, such as a Twitter post or a Facebook post or whatever kind 6 00:00:20,490 --> 00:00:21,120 ‫of post. 7 00:00:21,120 --> 00:00:28,860 ‫And the idea is that I want to inherit from post and I want to create something like an image post or 8 00:00:28,860 --> 00:00:36,150 ‫later a video post, and those kind of things are going to enable us to understand the concept a bit 9 00:00:36,150 --> 00:00:42,390 ‫better of inheritance, and you can apply that onto different objects and different situations in the 10 00:00:42,390 --> 00:00:43,050 ‫future. 11 00:00:43,050 --> 00:00:53,070 ‫So first of all, a post has a variable which I'm going to make private static in current post ID. 12 00:00:53,070 --> 00:00:57,810 ‫So this one is going to be a field of that post and it's static. 13 00:00:57,810 --> 00:01:00,810 ‫So it's available outside of this post as well. 14 00:01:00,810 --> 00:01:04,770 ‫And it will be created once the application is started. 15 00:01:04,770 --> 00:01:05,160 ‫Right. 16 00:01:05,160 --> 00:01:09,390 ‫So what we can do is, first of all, create some properties. 17 00:01:09,840 --> 00:01:15,960 ‫And now the idea behind properties, as you know, is they give you some more information about the 18 00:01:15,960 --> 00:01:17,130 ‫object, right. 19 00:01:17,130 --> 00:01:22,650 ‫So in our case, if I create an object of post, there are certain information that we really want to 20 00:01:22,650 --> 00:01:22,920 ‫have. 21 00:01:22,920 --> 00:01:29,760 ‫For example, we want to know the ID well as a admin, as a programmer, not that much as a user. 22 00:01:29,760 --> 00:01:36,090 ‫And end user is not interested in the post ID, but as an admin or as the program you should be because 23 00:01:36,090 --> 00:01:40,050 ‫every post should be identified and it should have a unique ID. 24 00:01:40,140 --> 00:01:42,750 ‫So we're going to have IDs. 25 00:01:42,750 --> 00:01:44,370 ‫We need a title. 26 00:01:44,370 --> 00:01:48,990 ‫So for example, the Post has a title, maybe a description or a text, something like that. 27 00:01:48,990 --> 00:01:53,940 ‫Then we need to know who sent that post and whether it should be public or not. 28 00:01:54,030 --> 00:01:59,790 ‫Of course, there is a lot more to know about a post or there can be a lot more properties in a post, 29 00:01:59,790 --> 00:02:02,220 ‫but we are going to keep it simple for now. 30 00:02:02,220 --> 00:02:11,310 ‫So I'm going to create protected properties here and we have not used protected properties yet, but 31 00:02:11,310 --> 00:02:17,310 ‫in the end protect means that it can only be used by this class, by the post class and any deriving 32 00:02:17,310 --> 00:02:20,670 ‫classes, so classes which derive from post. 33 00:02:20,670 --> 00:02:30,810 ‫So I'm going to go ahead and create the first one which is going to be the ID, so int I d and we're 34 00:02:30,810 --> 00:02:33,300 ‫going to use get and set. 35 00:02:34,820 --> 00:02:36,500 ‫Then another property. 36 00:02:36,500 --> 00:02:45,950 ‫So I'm going to use Prop here and it should be a string and I'm going to call it title and as before 37 00:02:45,950 --> 00:02:47,180 ‫it should be protected. 38 00:02:48,890 --> 00:02:56,990 ‫Then another property and I'm going to use string again and this one will be send by user name. 39 00:02:57,440 --> 00:03:01,850 ‫So who sent it and it's going to be selected as well. 40 00:03:01,940 --> 00:03:08,690 ‫And finally, a property called is public. 41 00:03:08,900 --> 00:03:11,840 ‫So it's a boolean because it can only have two values. 42 00:03:11,840 --> 00:03:14,480 ‫So either it is public or it is not public. 43 00:03:14,570 --> 00:03:16,960 ‫So we have simply these properties, right? 44 00:03:16,970 --> 00:03:23,300 ‫So now we create a default constructor and there's something to know about the default constructor. 45 00:03:23,300 --> 00:03:24,320 ‫If derived. 46 00:03:24,320 --> 00:03:30,380 ‫If a draft class does not invoke a base clause constructor explicitly, the default constructor is called 47 00:03:30,380 --> 00:03:31,280 ‫implicitly. 48 00:03:31,280 --> 00:03:32,720 ‫That's why we create one here. 49 00:03:32,720 --> 00:03:42,980 ‫So we create a public post, and now that post will be well, because we don't get any parameters here. 50 00:03:43,010 --> 00:03:47,450 ‫It will be defined or we will set the values here, so ID will be zero. 51 00:03:47,480 --> 00:03:55,400 ‫Then the title is for example, my first post, or maybe with empty spaces. 52 00:03:55,400 --> 00:03:59,750 ‫First post like that then is it public? 53 00:03:59,750 --> 00:04:06,440 ‫Well, let's say true because we want to see it and then send by username well sent by me. 54 00:04:06,440 --> 00:04:08,270 ‫So then is new to in this case. 55 00:04:08,510 --> 00:04:12,650 ‫So whenever we create a post now it's just going to be this post here. 56 00:04:12,650 --> 00:04:15,950 ‫So it's going to be my first post, right? 57 00:04:15,950 --> 00:04:22,850 ‫Then I want to have another instance constructor that has several parameters. 58 00:04:22,850 --> 00:04:27,710 ‫So I want to create posts where I actually can define those things. 59 00:04:27,710 --> 00:04:30,260 ‫I don't define the ID, but I can define the title. 60 00:04:30,260 --> 00:04:35,120 ‫I can say whether it's public and whether it's sent by which username. 61 00:04:35,120 --> 00:04:41,630 ‫So you can imagine that let's say you write a little social media program and you want to have the capability 62 00:04:41,630 --> 00:04:46,220 ‫of posting, and then you need to send those information whenever you create a post. 63 00:04:46,220 --> 00:04:53,420 ‫So a user creates a post, it gets an automatically defined ID, then it gets an automatically defined 64 00:04:53,420 --> 00:04:57,080 ‫or it gets a defined title based on what the user has entered. 65 00:04:57,080 --> 00:05:02,090 ‫It is public based on what the user has ticked, whether he decided to make it public or not, and it's 66 00:05:02,090 --> 00:05:03,260 ‫sent by him. 67 00:05:03,260 --> 00:05:07,340 ‫So that's just data that is given over whenever a post is created. 68 00:05:07,340 --> 00:05:15,230 ‫So now let's create an instance constructor that has three parameters. 69 00:05:16,100 --> 00:05:22,280 ‫So I'm going to create public post and here I'm going to use the string title. 70 00:05:23,900 --> 00:05:38,180 ‫Bool is public and string send by username and in here I will set the ID and for that I will need something. 71 00:05:38,180 --> 00:05:40,370 ‫So I'm just going to set it to zero now. 72 00:05:40,370 --> 00:05:46,880 ‫But I will need an additional method which will always create a new ID for each post and we will see 73 00:05:46,910 --> 00:05:48,110 ‫how that works in a second. 74 00:05:48,110 --> 00:05:51,410 ‫So this title is going to be title. 75 00:05:51,890 --> 00:06:02,990 ‫This sent by username is going to be sent by username with a uncapped letter here and this dot is public 76 00:06:02,990 --> 00:06:09,740 ‫is going to be is public and not the property but this parameter. 77 00:06:09,740 --> 00:06:12,710 ‫So now I set that I don't want it to be zero. 78 00:06:12,710 --> 00:06:13,850 ‫The ID should be unique. 79 00:06:13,850 --> 00:06:22,760 ‫So the best way is to create a method which is going to be protected and it's called get next ID. 80 00:06:23,120 --> 00:06:31,520 ‫What that will do is it will simply return the next ID, which means current post ID and here we increment 81 00:06:31,940 --> 00:06:32,600 ‫before that. 82 00:06:32,600 --> 00:06:35,810 ‫So each time it's called, it's going to increment itself by one. 83 00:06:35,810 --> 00:06:40,070 ‫So this one here, this current post ID will be increased by one. 84 00:06:40,340 --> 00:06:47,810 ‫So now instead of setting zero here, we are going to call the next ID or get next ID method. 85 00:06:48,650 --> 00:06:53,420 ‫Now what else would you like to have in such a program where you can post something? 86 00:06:53,840 --> 00:06:56,720 ‫Well, I guess the capability of adjusting a post. 87 00:06:56,720 --> 00:07:02,480 ‫So for now we created a post and we would be pretty unhappy if we cannot change that post. 88 00:07:02,480 --> 00:07:09,230 ‫And well, that's something that does actually happen in I think what Snapchat or there you create a 89 00:07:09,230 --> 00:07:10,730 ‫picture and then it's there. 90 00:07:10,760 --> 00:07:16,640 ‫You cannot edit that picture, not sure whether you can edit the text, but here we want to be able 91 00:07:16,640 --> 00:07:25,550 ‫to edit the text so we will create a new method public void update and that should take in the title. 92 00:07:25,700 --> 00:07:34,310 ‫And the pool is public because if you think about it, what should the user be able to update? 93 00:07:34,660 --> 00:07:36,760 ‫He shouldn't be able to update the ID. 94 00:07:36,790 --> 00:07:41,200 ‫Neither should he be able to update the username because it's sent by him. 95 00:07:41,200 --> 00:07:47,200 ‫So he has a username and it shouldn't have impact onto the update of a post. 96 00:07:47,200 --> 00:07:52,780 ‫So in here we're just going to update the post and it means we're only going to change the title and 97 00:07:52,780 --> 00:07:55,840 ‫change the boolean, which is whether it's public or not. 98 00:07:56,110 --> 00:08:06,040 ‫And in here we simply say this title is going to be title, and this that is public is going to be public. 99 00:08:06,040 --> 00:08:09,640 ‫So that means, as we have here, a post. 100 00:08:10,150 --> 00:08:12,940 ‫A post is a blueprint. 101 00:08:12,940 --> 00:08:16,030 ‫Well, this class is a blueprint of any post instance. 102 00:08:16,030 --> 00:08:21,340 ‫So whenever we post something that is that self, that instance is the post. 103 00:08:21,340 --> 00:08:25,540 ‫And if we change its title, we change the title of that specific post. 104 00:08:25,540 --> 00:08:31,180 ‫And if we change, whether it's public or not, we change the publicity of that specific post. 105 00:08:31,990 --> 00:08:37,690 ‫So that enables us to update the title and it's publicity of an existing post. 106 00:08:37,690 --> 00:08:45,310 ‫So now the next one that I want to create is a virtual method override of two string that is inherited 107 00:08:45,310 --> 00:08:47,200 ‫from system dot object. 108 00:08:47,200 --> 00:08:55,600 ‫So System Dot object is a class that comes here in system. 109 00:08:55,600 --> 00:08:57,040 ‫So we can use that. 110 00:08:57,070 --> 00:09:00,070 ‫It's within C-sharp and we can simply use it. 111 00:09:00,070 --> 00:09:07,300 ‫And there is a method called to string or actually there from there we can call the two string method. 112 00:09:08,600 --> 00:09:09,410 ‫So. 113 00:09:09,770 --> 00:09:10,430 ‫System. 114 00:09:10,430 --> 00:09:17,150 ‫But object has a two string method and we want to override that because every single class so our post 115 00:09:17,150 --> 00:09:23,300 ‫class as well is inheriting from that object class. 116 00:09:23,300 --> 00:09:27,230 ‫So system that object is a class from which we can inherit. 117 00:09:27,230 --> 00:09:34,430 ‫So in here that object, for example, we can inherit from that or we do actually every class inherits 118 00:09:34,430 --> 00:09:34,880 ‫from that. 119 00:09:34,880 --> 00:09:40,310 ‫So now what we can do is we can override one of its methods. 120 00:09:40,310 --> 00:09:47,000 ‫So public override, string and two string. 121 00:09:47,360 --> 00:09:49,730 ‫As you can see, it already proposes this. 122 00:09:49,730 --> 00:09:55,460 ‫So it says returns a string that represents the current object that something that is within the object 123 00:09:55,460 --> 00:09:55,910 ‫class. 124 00:09:55,910 --> 00:09:59,540 ‫And as you can see there is something called return based to string. 125 00:09:59,540 --> 00:10:07,010 ‫So the base class has a two string method and if we just do that then it will then just pretty much 126 00:10:07,010 --> 00:10:13,850 ‫will mean nothing because we simply will use the two string method of the base class anyways. 127 00:10:14,060 --> 00:10:20,000 ‫But we can change that so we can adjust instead of returning whatever the base class would return. 128 00:10:20,000 --> 00:10:28,010 ‫We want to do our own thing, so we're going to use string format in order to format a string which 129 00:10:28,010 --> 00:10:30,860 ‫is going to have certain information. 130 00:10:30,860 --> 00:10:35,810 ‫So it's going to be the ID, it's going to be the title and who send it. 131 00:10:36,320 --> 00:10:42,590 ‫So I'm just going to use this kind of information like that. 132 00:10:42,590 --> 00:10:53,030 ‫So it's going to be this ID, so the ID, then this, the title, and finally this dot sent by username. 133 00:10:54,590 --> 00:10:57,320 ‫So that's what is going to return. 134 00:10:57,320 --> 00:11:02,750 ‫So whenever we use two string, it's not going to return simply some information about the object, 135 00:11:02,750 --> 00:11:07,790 ‫but it's going to return it in the standard format or in our format that we have created. 136 00:11:07,790 --> 00:11:09,470 ‫So this is our format. 137 00:11:10,670 --> 00:11:11,270 ‫All right. 138 00:11:11,630 --> 00:11:12,560 ‫So. 139 00:11:13,670 --> 00:11:16,670 ‫Let's create an object of that class. 140 00:11:16,670 --> 00:11:21,350 ‫So let's go ahead into our program and then here let's create a post. 141 00:11:21,830 --> 00:11:27,080 ‫So post post one is new post. 142 00:11:27,080 --> 00:11:29,840 ‫And here I can enter some information or I can leave it. 143 00:11:29,840 --> 00:11:33,740 ‫So if I leave it, that's the default constructor that will be called. 144 00:11:34,160 --> 00:11:35,720 ‫So that one here. 145 00:11:36,110 --> 00:11:39,110 ‫And if I don't, then a different one will be called. 146 00:11:39,110 --> 00:11:42,150 ‫So let's say I posted something. 147 00:11:42,170 --> 00:11:46,400 ‫Thanks for the birthday wishes. 148 00:11:46,400 --> 00:11:49,580 ‫So everybody wished me a happy birthday. 149 00:11:49,580 --> 00:11:55,130 ‫So I'm just going to say thank you very much and I want to make it true because I want my friends to 150 00:11:55,130 --> 00:11:56,560 ‫see it so it should be public. 151 00:11:56,570 --> 00:12:01,010 ‫And then Dennis Pan, Utah, is the one sending it. 152 00:12:01,520 --> 00:12:07,220 ‫Of course, we could have a user class which does all of the handling and we could simply check which 153 00:12:07,220 --> 00:12:08,630 ‫users logged in or whatever. 154 00:12:08,630 --> 00:12:13,130 ‫But for now we just use a hardcoded string here. 155 00:12:13,130 --> 00:12:15,050 ‫So it's going to be Dennis, Utah. 156 00:12:15,380 --> 00:12:21,260 ‫So that's a new post that we have here and now we can go ahead and write that onto the console. 157 00:12:21,260 --> 00:12:30,620 ‫So W and I'm going to say post dot to string and here of course the post one. 158 00:12:30,620 --> 00:12:38,840 ‫So our post instance, so this one is our post instance and I call the post one and it's going to write 159 00:12:38,840 --> 00:12:44,150 ‫something on the console and as we want to see what it is, we need to realign here. 160 00:12:44,510 --> 00:12:49,190 ‫So we just want to keep the console open so that we see what's happening there. 161 00:12:49,910 --> 00:12:56,150 ‫And then we are, as you can see, one, thanks for this birthday, birthday which is by Dennis Panetta 162 00:12:56,150 --> 00:13:01,610 ‫and this one is the ID of this post. 163 00:13:01,610 --> 00:13:04,490 ‫So that means that our post here. 164 00:13:06,360 --> 00:13:13,350 ‫This one gets a new ID and the new ID is going to be zero plus plus one or plus one, which means it's 165 00:13:13,350 --> 00:13:14,270 ‫just one. 166 00:13:14,280 --> 00:13:16,950 ‫So that's why we get this one here. 167 00:13:17,070 --> 00:13:22,670 ‫So the ID is one, then that's the post info and that's who send it by Dennis Pan. 168 00:13:23,310 --> 00:13:27,600 ‫So now we have a post and now let's go ahead and use inheritance. 169 00:13:27,600 --> 00:13:34,500 ‫Because so far, except for maybe this two string here, there is actually no inheritance. 170 00:13:34,770 --> 00:13:37,430 ‫So actually, just for you. 171 00:13:37,440 --> 00:13:44,580 ‫So you know what I said earlier, virtual method override of the two string method that is inherited 172 00:13:44,580 --> 00:13:46,260 ‫from system that object. 173 00:13:46,650 --> 00:13:50,190 ‫So now let's create a new class. 174 00:13:51,150 --> 00:14:00,120 ‫And that one will be image post because well, so far we can only post certain simple text, but in 175 00:14:00,120 --> 00:14:03,170 ‫the future we also want to post images. 176 00:14:03,180 --> 00:14:08,850 ‫And now that image posts should be a deriving class of our base class post. 177 00:14:08,850 --> 00:14:14,730 ‫Because this class here is a very simple class and we want to go ahead and inherit from it. 178 00:14:14,730 --> 00:14:20,610 ‫So in order to inherit from another class, you use colon and then you enter the name of the class you 179 00:14:20,610 --> 00:14:21,630 ‫want to inherit from. 180 00:14:21,630 --> 00:14:24,210 ‫So I want to inherit from post. 181 00:14:24,210 --> 00:14:27,830 ‫And what that allows me is to use all of its functionality. 182 00:14:27,840 --> 00:14:33,360 ‫That's something that's pretty cool because now I can use its properties, I can use its variables except 183 00:14:33,360 --> 00:14:35,370 ‫for its constructor here. 184 00:14:36,000 --> 00:14:39,050 ‫And yeah, so let's go ahead and do that. 185 00:14:39,990 --> 00:14:42,600 ‫And let's extend the image post. 186 00:14:42,600 --> 00:14:51,510 ‫So as you know, it derives from post and now it should have another property called image URL and to 187 00:14:51,510 --> 00:14:52,410 ‫constructors. 188 00:14:52,410 --> 00:14:54,080 ‫So that's what I want to add. 189 00:14:54,090 --> 00:15:00,330 ‫So first I need a property here and it will be a string called image. 190 00:15:00,330 --> 00:15:05,970 ‫You are l that will be the image url of the image post. 191 00:15:05,970 --> 00:15:09,060 ‫So let's say we post something and there is an image in it. 192 00:15:09,060 --> 00:15:13,680 ‫Then it's automatically or it should be an image post and it needs to have an image URL. 193 00:15:13,680 --> 00:15:21,060 ‫So a location where that image is stored and that can be on our servers or it could be simply on the 194 00:15:21,060 --> 00:15:21,780 ‫internet. 195 00:15:21,780 --> 00:15:27,780 ‫So whatever is there, we have this or you need to have this image URL for an image post. 196 00:15:28,260 --> 00:15:36,450 ‫Now let's create a very simple constructor, public image post 197 00:15:39,030 --> 00:15:41,100 ‫just like that, nothing else. 198 00:15:41,100 --> 00:15:42,570 ‫As you can see, there is nothing in there. 199 00:15:42,570 --> 00:15:44,370 ‫I don't want to do anything in here. 200 00:15:45,960 --> 00:15:52,200 ‫And then I create another post here or image post constructor. 201 00:15:52,290 --> 00:15:55,860 ‫But this time I want some parameters in here. 202 00:15:55,860 --> 00:16:08,040 ‫So it's going to be string title, string send by username, string image URL and actually u r l and 203 00:16:08,040 --> 00:16:10,140 ‫bool is public. 204 00:16:10,830 --> 00:16:12,840 ‫So I want to have all of those. 205 00:16:13,620 --> 00:16:17,700 ‫And now in the image post I want to set the ID again. 206 00:16:17,700 --> 00:16:25,190 ‫This dot id is equal to get next id and that's something that's pretty cool already. 207 00:16:25,200 --> 00:16:27,030 ‫Where the hell is this ID coming from? 208 00:16:27,030 --> 00:16:29,820 ‫And where is this get next ID coming from? 209 00:16:29,820 --> 00:16:31,560 ‫Well, it's coming from post. 210 00:16:31,560 --> 00:16:36,240 ‫So we are taking this method here, this protected method. 211 00:16:36,240 --> 00:16:39,840 ‫We can simply call it in here, we can use it as if it is ours. 212 00:16:39,840 --> 00:16:47,190 ‫So we don't even need to say something like post dot get next ID, we simply say get next ID and the 213 00:16:47,190 --> 00:16:48,540 ‫same thing for this ID. 214 00:16:48,570 --> 00:16:53,250 ‫So each image post has an ID, the same thing as the post itself. 215 00:16:53,400 --> 00:16:57,090 ‫And now that's true for the title as well. 216 00:16:57,090 --> 00:16:59,370 ‫So title is going to be title. 217 00:17:00,510 --> 00:17:06,690 ‫Then this dot send by username is going to be sent by username. 218 00:17:08,160 --> 00:17:12,600 ‫And finally, this is public is going to be is public. 219 00:17:14,700 --> 00:17:16,320 ‫Now, that's pretty cool. 220 00:17:16,350 --> 00:17:18,070 ‫We can use those things. 221 00:17:18,090 --> 00:17:18,720 ‫That's great. 222 00:17:18,720 --> 00:17:24,240 ‫And now we also have our own property, which is our image URL and we have that here. 223 00:17:24,240 --> 00:17:30,960 ‫So whenever an image post is created, the image URL has to be given over as an argument. 224 00:17:30,960 --> 00:17:36,000 ‫So we say this image URL is going to be the image URL. 225 00:17:36,270 --> 00:17:41,370 ‫So on one hand, we have the ones inherited from post. 226 00:17:43,000 --> 00:17:45,090 ‫So I'm gonna add that here. 227 00:17:45,100 --> 00:17:49,000 ‫And on the other hand, we have the one that is our own member. 228 00:17:49,000 --> 00:17:53,230 ‫So property image URL is a member of image post but not of post. 229 00:17:53,230 --> 00:17:54,670 ‫And that's something that's important. 230 00:17:54,670 --> 00:17:58,600 ‫So Post doesn't know about this image URL and it doesn't matter. 231 00:17:59,140 --> 00:18:05,170 ‫But our image post knows about all of the properties of our post, so that's inheritance. 232 00:18:07,060 --> 00:18:09,970 ‫Now, one little thing about this image post here. 233 00:18:10,270 --> 00:18:11,080 ‫So. 234 00:18:11,970 --> 00:18:19,410 ‫The constructors are required those two because neither constructor calls a base class. 235 00:18:20,080 --> 00:18:25,870 ‫So we don't use this based out calling the constructor of the base class and the default constructor 236 00:18:25,870 --> 00:18:31,180 ‫in the base class is called implicitly because we don't call it explicitly in here. 237 00:18:31,180 --> 00:18:37,390 ‫So neither in this one and nor in this one, the one from the base class, the constructor. 238 00:18:37,390 --> 00:18:46,220 ‫So this default constructor must be called or there must be a base constructor within our post. 239 00:18:46,300 --> 00:18:47,290 ‫That's why I created it. 240 00:18:47,290 --> 00:18:49,780 ‫Because you might have wondered, why do we need that? 241 00:18:49,810 --> 00:18:51,220 ‫Why is it there? 242 00:18:51,250 --> 00:18:55,480 ‫Well, it's required because we don't explicitly call it. 243 00:18:55,570 --> 00:18:56,680 ‫That's on. 244 00:18:56,710 --> 00:18:58,360 ‫And it will be implicitly called. 245 00:18:58,740 --> 00:18:59,320 ‫Right. 246 00:18:59,950 --> 00:19:00,550 ‫Great. 247 00:19:00,550 --> 00:19:01,840 ‫So that's that. 248 00:19:01,840 --> 00:19:07,060 ‫Let's go ahead into our program class and create one of those posts. 249 00:19:07,720 --> 00:19:16,240 ‫And I'm going to create an image post now and it's going to be a new image post and actually give it 250 00:19:16,240 --> 00:19:16,930 ‫a name. 251 00:19:17,440 --> 00:19:19,150 ‫I'm going to call it Image Post one. 252 00:19:19,900 --> 00:19:21,910 ‫It's going to be a new image post. 253 00:19:22,540 --> 00:19:31,660 ‫And I'm going to check out my new shoes because I bought some new shoes and they are freaking awesome. 254 00:19:32,230 --> 00:19:33,700 ‫And who sent it? 255 00:19:33,700 --> 00:19:37,210 ‫Well, Dennis Panetta was super hyped about his new shoes. 256 00:19:37,210 --> 00:19:40,510 ‫And of course, he needs to have a link for those images. 257 00:19:40,510 --> 00:19:46,420 ‫Well, he just uploaded the image, but the image itself has a link because it's stored somewhere in 258 00:19:46,420 --> 00:19:50,200 ‫our storage, so or in our servers. 259 00:19:50,200 --> 00:19:56,020 ‫So it's going to be a secure https and I'm just going to fake a link here. 260 00:19:56,020 --> 00:20:03,340 ‫I'm just going to call it images, dot com slash shoes and well, he made it public. 261 00:20:03,340 --> 00:20:04,150 ‫So it's true. 262 00:20:04,980 --> 00:20:08,850 ‫And let's put it onto the next line so it's easier to read. 263 00:20:09,060 --> 00:20:15,120 ‫So now we have our image post and what we can do with the image post now is to write something on the 264 00:20:15,120 --> 00:20:17,220 ‫console again to see what's going on. 265 00:20:17,220 --> 00:20:23,940 ‫And I'm just going to call image post 1.2 string and that's again something that's pretty cool. 266 00:20:24,120 --> 00:20:27,930 ‫So we call this two string method on our image post one. 267 00:20:28,050 --> 00:20:30,690 ‫And do you see each string method in here? 268 00:20:30,780 --> 00:20:31,730 ‫I don't. 269 00:20:31,740 --> 00:20:37,740 ‫And that's cool because we take the one from our post, so we inherit from post and now we take its 270 00:20:37,740 --> 00:20:40,110 ‫method, which is called two string. 271 00:20:40,110 --> 00:20:41,730 ‫And if we run that. 272 00:20:42,930 --> 00:20:46,050 ‫Actually, we need to stop running it. 273 00:20:47,470 --> 00:20:48,790 ‫Because we won't see it. 274 00:20:49,000 --> 00:20:51,150 ‫There is a reed and it's gone. 275 00:20:51,160 --> 00:20:54,940 ‫So we need to take this red line and post it right here. 276 00:20:55,210 --> 00:20:59,770 ‫So let's run it again and it says, Check out my new shoes by Dennis Panetta. 277 00:20:59,770 --> 00:21:01,020 ‫But where is the link? 278 00:21:01,030 --> 00:21:01,900 ‫I need the link. 279 00:21:01,900 --> 00:21:03,190 ‫Come on, give me the link. 280 00:21:03,640 --> 00:21:08,940 ‫Well, it's not there because the two string method of our post doesn't know about links. 281 00:21:08,950 --> 00:21:11,310 ‫It has no clue about links. 282 00:21:11,320 --> 00:21:12,340 ‫It doesn't care about links. 283 00:21:12,340 --> 00:21:13,850 ‫It doesn't need any. 284 00:21:13,870 --> 00:21:16,180 ‫So a little challenge for you. 285 00:21:16,180 --> 00:21:19,360 ‫And that's how we're going to finish the video for now. 286 00:21:19,450 --> 00:21:27,550 ‫Please create a two string method within our image post that also informs us about the link. 287 00:21:29,750 --> 00:21:30,020 ‫All right. 288 00:21:30,020 --> 00:21:30,970 ‫I hope you tried it. 289 00:21:30,980 --> 00:21:33,590 ‫So what I'm going to do is I'm going to keep it simple. 290 00:21:33,590 --> 00:21:43,580 ‫I'm going to copy the two string from here into our image post, and I'm going to change the format 291 00:21:43,580 --> 00:21:44,660 ‫just a little bit. 292 00:21:45,880 --> 00:21:49,420 ‫I'm going to add a little statement in here. 293 00:21:49,420 --> 00:21:54,100 ‫So too is going to be the link and three is still going to be the user. 294 00:21:54,100 --> 00:21:56,350 ‫So we need the link here. 295 00:21:56,350 --> 00:22:09,100 ‫So this dot image URL comma, so the order is ID title, the URL and then sent by user. 296 00:22:09,100 --> 00:22:12,880 ‫So if you do that, we override from the base clause. 297 00:22:12,880 --> 00:22:20,890 ‫So we override the two string from our post which overloaded from the system object. 298 00:22:20,890 --> 00:22:24,190 ‫So you can see you can override it and override it and so forth. 299 00:22:24,190 --> 00:22:26,950 ‫And we will see where the limit is or how we can limit that. 300 00:22:26,950 --> 00:22:28,540 ‫So now let's run it. 301 00:22:29,440 --> 00:22:30,140 ‫And we can see. 302 00:22:30,160 --> 00:22:31,210 ‫Check out my new shoes. 303 00:22:31,210 --> 00:22:32,060 ‫Here's the link. 304 00:22:32,080 --> 00:22:32,950 ‫Dennis Panetta. 305 00:22:33,100 --> 00:22:35,590 ‫So now i can click on the link in the console. 306 00:22:35,590 --> 00:22:35,950 ‫I can't. 307 00:22:35,950 --> 00:22:41,530 ‫But generally I could click on the link and I could see the image or my tool, my app, for example, 308 00:22:41,530 --> 00:22:43,630 ‫could read that link and show the image. 309 00:22:44,740 --> 00:22:45,250 ‫All right. 310 00:22:45,250 --> 00:22:49,110 ‫So that's a first glimpse into inheritance. 311 00:22:49,120 --> 00:22:50,020 ‫It was a long video. 312 00:22:50,020 --> 00:22:50,590 ‫I know that. 313 00:22:50,590 --> 00:22:53,260 ‫And inheritance is a lot more than that. 314 00:22:53,260 --> 00:22:55,600 ‫And we will look into a lot cooler things. 315 00:22:55,600 --> 00:23:00,010 ‫But first of all, we're going to go to a challenge in the next video. 316 00:23:00,010 --> 00:23:03,850 ‫And so see you in the next video.