1 00:00:12,200 --> 00:00:16,350 Welcome to my lovely students, very happy that you're here with me. 2 00:00:16,370 --> 00:00:19,850 Let's go over the inheritance practice assignments. 3 00:00:20,390 --> 00:00:27,860 OK, so we have covered all the theory topics and it's now time to practice, OK, practice time of 4 00:00:27,860 --> 00:00:28,220 war. 5 00:00:28,370 --> 00:00:30,410 We need to defeat the assignment. 6 00:00:30,410 --> 00:00:33,850 We need to break it down into pieces and we need to get the resolution. 7 00:00:34,610 --> 00:00:36,110 This is not an easy task. 8 00:00:36,110 --> 00:00:38,960 So it would be a bit more challenging than previous ones. 9 00:00:38,960 --> 00:00:40,160 And it's OK. 10 00:00:40,190 --> 00:00:43,900 Even if you get partial resolution, you need to try. 11 00:00:44,000 --> 00:00:45,140 You need to fight with it. 12 00:00:45,140 --> 00:00:48,460 You need to get the resolution by yourself and not just to see the answers. 13 00:00:48,470 --> 00:00:54,530 OK, so I highly recommend you to try to resolve it by yourself and in the next video to compare your 14 00:00:54,530 --> 00:00:55,460 answers to mine. 15 00:00:56,270 --> 00:00:57,370 OK, so let's begin. 16 00:00:58,040 --> 00:01:05,480 First of all, obviously, I would ask you to create two classes, one parent class employee, and the 17 00:01:05,480 --> 00:01:07,640 second one would be child class programer. 18 00:01:08,570 --> 00:01:17,660 And you would obviously have a relationship of parent child between these two classes as employee. 19 00:01:17,870 --> 00:01:25,160 Could be either a child, which is a programmer, it could be a product manager, a Q a teacher or other 20 00:01:25,160 --> 00:01:27,710 positions in the IT industry. 21 00:01:27,750 --> 00:01:33,290 OK, but we are going to focus only on one child, which we which will be a programmer. 22 00:01:33,530 --> 00:01:36,890 So we need to create these two classes, parent and child. 23 00:01:37,850 --> 00:01:43,720 OK, so first of all, let's talk about the parent, the employee class and what it will contain. 24 00:01:44,540 --> 00:01:50,750 You would need to create an input method and constructor or init method. 25 00:01:50,750 --> 00:01:58,970 It's the same name for the employee class and it would contain three properties, OK, it would contain 26 00:01:59,450 --> 00:02:09,590 years of experience, position, name and employee name, OK, and then afterwards create a method. 27 00:02:09,950 --> 00:02:12,320 First one we would talk about the second one as well. 28 00:02:12,860 --> 00:02:17,240 The first method inside employee, which with name would be calculate salary. 29 00:02:17,900 --> 00:02:27,020 In here we would need to create a variable, a local variable with an aim calculated salary based on 30 00:02:27,020 --> 00:02:28,160 these parameters. 31 00:02:28,580 --> 00:02:36,860 First of all, create an additional variable and call it base salary in it will be equals to two thousand 32 00:02:36,860 --> 00:02:37,640 five hundred. 33 00:02:38,120 --> 00:02:47,290 Then we're going to add to that base salary, additional money according to the following parameters. 34 00:02:47,810 --> 00:02:53,150 So each employee, each programmer in our case, each employee. 35 00:02:53,150 --> 00:03:00,110 Yeah, each employee would get increase if he has between zero and two years of experience. 36 00:03:01,810 --> 00:03:04,170 Including two years. 37 00:03:04,220 --> 00:03:11,530 OK, so you remember that once we do in comparison, you can do X bigger and you can do also. 38 00:03:11,530 --> 00:03:17,560 The use also equals bigger and not just bigger, right. 39 00:03:18,040 --> 00:03:19,800 So including two. 40 00:03:19,930 --> 00:03:26,440 So between zero and two years of experience, the salary would increase by 1500, meaning this base 41 00:03:26,440 --> 00:03:26,900 salary. 42 00:03:27,670 --> 00:03:37,150 OK, then you have another if if it's if years of experience is between two and five years, including 43 00:03:37,150 --> 00:03:40,840 five salary, it would be increased by two thousand five hundred. 44 00:03:41,590 --> 00:03:50,230 And if that are years of experience is above five years, the base salary would increase by three thousand 45 00:03:50,230 --> 00:03:52,300 five hundred, obviously. 46 00:03:52,730 --> 00:03:55,660 Here I am talking about years of experience. 47 00:03:56,120 --> 00:04:00,980 I mean, you need to use this property right here, OK? 48 00:04:01,060 --> 00:04:02,710 You need to use it inside this method. 49 00:04:04,440 --> 00:04:16,290 Then print the calculated salary and also return the calculated return, the calculated salary. 50 00:04:16,450 --> 00:04:25,050 OK, and you will see why, OK, you already familiar with the return keyword from previous topic topics? 51 00:04:25,050 --> 00:04:25,590 Obviously. 52 00:04:25,740 --> 00:04:29,100 OK, then we have a second method inside the parent. 53 00:04:29,100 --> 00:04:30,130 Inside the employee. 54 00:04:30,210 --> 00:04:38,740 OK, it would calculate the salary based on two properties position, name and years of experience. 55 00:04:38,760 --> 00:04:42,640 OK, again, meaning using these properties right here. 56 00:04:42,990 --> 00:04:46,560 OK, so it would take into consideration these two. 57 00:04:48,470 --> 00:04:55,760 And it would calculate whether the employee needs to get a bonus or not, so creative calculation, 58 00:04:55,760 --> 00:05:01,250 both based on these following parameters, first of all. 59 00:05:02,390 --> 00:05:11,900 I also want to mention here to accept pass the calculated salary variable. 60 00:05:14,000 --> 00:05:20,090 And add bonus on top of it. 61 00:05:21,040 --> 00:05:29,900 OK, so what I mean is, is this method right here or should accept calculated salary? 62 00:05:31,310 --> 00:05:38,630 And on top of that, you should add, OK, you should add, if an employee deserves a bonus, you should 63 00:05:38,630 --> 00:05:40,220 add it on top of this variable. 64 00:05:44,480 --> 00:05:46,140 And how would you do it? 65 00:05:46,160 --> 00:05:51,110 I'm just also I'm like thinking of giving you an additional hint, OK, so I will do it. 66 00:05:52,040 --> 00:05:58,100 So, for example, if I have a variable, for example, if I have instant's, which will be instant's, 67 00:05:59,240 --> 00:06:05,020 maybe programer, maybe like a person, a person, one. 68 00:06:05,060 --> 00:06:07,540 OK, and then we have method one. 69 00:06:08,240 --> 00:06:12,560 So if I have a return action here and sign it said this method. 70 00:06:12,570 --> 00:06:12,950 Yeah. 71 00:06:14,090 --> 00:06:17,480 Inside its method, let's say I have a return action. 72 00:06:17,480 --> 00:06:19,000 Same as I have here. 73 00:06:19,010 --> 00:06:19,370 Yeah. 74 00:06:19,790 --> 00:06:24,080 So if I have a return here I can do the following thing. 75 00:06:26,660 --> 00:06:27,850 I can do this thing. 76 00:06:27,890 --> 00:06:28,310 Yeah. 77 00:06:29,450 --> 00:06:38,090 And that way if I have a return here it will be accepted and sent to here and then this variable I can 78 00:06:38,090 --> 00:06:38,600 use it. 79 00:06:38,610 --> 00:06:48,610 OK, I can do now person one, method two and now I can take this variable and pass it to here. 80 00:06:48,680 --> 00:06:49,120 Right. 81 00:06:49,910 --> 00:06:52,970 So this is exactly what you were asked to do. 82 00:06:53,120 --> 00:07:00,650 You should get this calculated salary, OK, and put it with by using the return action in that method 83 00:07:00,980 --> 00:07:04,930 and then send it to an outer variable like this. 84 00:07:04,940 --> 00:07:10,260 And then this variable should go into the candidates for bonus method. 85 00:07:11,030 --> 00:07:11,540 All right. 86 00:07:11,570 --> 00:07:15,630 So this is like a huge hand, but I think it will be very helpful. 87 00:07:16,340 --> 00:07:23,310 So use this calculated salary and then choose and check whether an employee deserves deserves a bonus. 88 00:07:23,330 --> 00:07:27,110 OK, so here are the following parameters. 89 00:07:27,410 --> 00:07:35,990 A bonus of zero point one out of the monthly calculated salary will be handed to if all front end developers. 90 00:07:36,840 --> 00:07:41,540 How could you check whether an employee is a front end developer? 91 00:07:41,900 --> 00:07:44,170 Check the hint at the end of the page. 92 00:07:44,780 --> 00:07:45,560 So. 93 00:07:46,520 --> 00:07:53,150 Before going to the end of the page, just remember that you have position name, which is a string, 94 00:07:53,660 --> 00:07:54,710 very important. 95 00:07:55,850 --> 00:07:59,510 You have this inside your instance that you need to create. 96 00:08:01,140 --> 00:08:10,950 And you can check whether the property that we just looked, if it contains a Front-End text, you can 97 00:08:10,950 --> 00:08:12,420 do it by the following way. 98 00:08:13,650 --> 00:08:14,190 OK. 99 00:08:15,480 --> 00:08:16,290 This is the hint. 100 00:08:17,950 --> 00:08:26,680 To check whether a certain phrase appears in another phrase by using and if you use the template, this 101 00:08:26,680 --> 00:08:28,240 one if. 102 00:08:29,380 --> 00:08:30,940 String ABC. 103 00:08:32,040 --> 00:08:33,300 Appears in. 104 00:08:34,520 --> 00:08:44,570 This ring ABCDE, then go inside if OK, so Python knows how to check if a certain string appears in 105 00:08:44,570 --> 00:08:51,380 a different string and this is the template, if there's a certain string, you see the quotation marks 106 00:08:51,380 --> 00:08:53,330 here, if a certain string. 107 00:08:54,200 --> 00:09:01,790 Appears in can see here the end in keyword appears in a different string than the if statement would 108 00:09:01,790 --> 00:09:02,450 go inside. 109 00:09:03,080 --> 00:09:04,100 So this is the hint. 110 00:09:06,830 --> 00:09:13,410 So a bonus of zero point one of a monthly calculated salary will be handed to all Fronton developers. 111 00:09:14,270 --> 00:09:23,690 OK, so check the hint that I just gave you how to check whether the position, the position contains 112 00:09:23,690 --> 00:09:24,890 this front end. 113 00:09:25,940 --> 00:09:26,390 OK. 114 00:09:28,290 --> 00:09:36,370 An additional bonus of zero point two will be given to all employees who has above two years of experience. 115 00:09:36,400 --> 00:09:41,770 OK, so all employees that have above two years of experience will get that bonus as well. 116 00:09:42,790 --> 00:09:44,790 Employees cannot get to bonuses. 117 00:09:44,800 --> 00:09:47,010 OK, take it into consideration. 118 00:09:48,010 --> 00:09:51,060 So this covers the second method. 119 00:09:51,310 --> 00:09:56,260 This covers the first method of the employee, which is the parent class. 120 00:09:57,380 --> 00:10:01,730 Now, let's talk about the child's class problem, how this class is a bit more. 121 00:10:02,660 --> 00:10:03,080 Yeah. 122 00:10:03,650 --> 00:10:07,710 So it should inherit all methods and properties, OK? 123 00:10:07,850 --> 00:10:16,910 Should there should be inheritance between programmer and employee and inside this class, you should 124 00:10:16,910 --> 00:10:22,370 get the properties, obviously the init method and also one method. 125 00:10:22,590 --> 00:10:28,290 OK, you should print salary and position in your own sentence. 126 00:10:28,310 --> 00:10:30,790 You can use it in whatever sentence you want. 127 00:10:30,800 --> 00:10:35,360 Just use these to two values, salary and position. 128 00:10:35,900 --> 00:10:36,380 All right. 129 00:10:37,850 --> 00:10:40,340 Use please use string formatting. 130 00:10:41,900 --> 00:10:46,690 As you can see, the programmer is very, very lean. 131 00:10:46,740 --> 00:10:52,510 OK, so I just want you to know what the name of the employee, OK? 132 00:10:52,520 --> 00:10:55,970 And I want it to be less challenging name. 133 00:10:57,770 --> 00:11:01,830 Of employee and position. 134 00:11:01,890 --> 00:11:03,740 OK, so print out these two values. 135 00:11:03,800 --> 00:11:12,290 OK, now once we have covered this class and we have covered this class, I want you to create these 136 00:11:12,290 --> 00:11:13,200 two instances. 137 00:11:13,220 --> 00:11:19,400 OK, so you have the first instance, junior python programmer, and it will get these three values, 138 00:11:20,000 --> 00:11:22,370 one front end. 139 00:11:22,940 --> 00:11:27,470 And Joseph, what all these three mean, very easy. 140 00:11:27,740 --> 00:11:28,520 One front. 141 00:11:28,520 --> 00:11:32,210 And Joseph, let's go to the parent one. 142 00:11:33,180 --> 00:11:42,180 Self years of experience, second front end is the positioning, then Joseph employee name. 143 00:11:42,650 --> 00:11:47,970 OK, so this is the first instance, which is junior python programmer. 144 00:11:47,990 --> 00:11:50,610 This is the name of the instance, the name of the instance. 145 00:11:50,790 --> 00:11:54,930 And these are the values that you should pass to the instance. 146 00:11:55,260 --> 00:11:58,220 You obviously need to create an instance of the child. 147 00:11:58,230 --> 00:11:58,520 Yeah. 148 00:12:00,260 --> 00:12:05,960 This is the second instance, this is its name, senior developes, and to get these three values, 149 00:12:05,960 --> 00:12:10,880 six years of experience, name of the position and the name of the person is Dan. 150 00:12:12,030 --> 00:12:12,610 That's it. 151 00:12:12,990 --> 00:12:18,900 So just going to this part here, you can see that this instance gets front end. 152 00:12:18,990 --> 00:12:20,640 This is the name of the position. 153 00:12:20,880 --> 00:12:30,510 And then going here, OK, you need to check whether it's front end is received by using. 154 00:12:32,670 --> 00:12:39,300 Positioning and the positioning, obviously, for that specific instance, is front end, so the employee 155 00:12:39,300 --> 00:12:40,510 should get this bonus. 156 00:12:40,530 --> 00:12:49,710 Yeah, I think this covers the readout and the walk through of the inheritance assignment, homework 157 00:12:49,710 --> 00:12:50,310 assignment. 158 00:12:50,550 --> 00:12:52,150 It will be challenging. 159 00:12:52,170 --> 00:12:52,920 It's OK. 160 00:12:53,550 --> 00:12:59,940 Just try and try to rely on previous topics and previous lectures regarding inheritance and OLP that 161 00:12:59,940 --> 00:13:00,570 we studied. 162 00:13:00,750 --> 00:13:03,030 I wish you good luck and I will see you in the next lecture. 163 00:13:03,090 --> 00:13:03,570 Thank you.