1
00:00:00,390 --> 00:00:05,490
One of the most popular questions in the interview is, of course, glasses, and you might get a question

2
00:00:05,490 --> 00:00:11,610
like this design a class for simply, which takes a different name during construction of object.

3
00:00:11,760 --> 00:00:13,470
And here's a sell at a property.

4
00:00:13,770 --> 00:00:18,690
So as you can see, we're not getting super strict requirements here, and we have some flexibility

5
00:00:18,690 --> 00:00:19,500
to implement it.

6
00:00:19,770 --> 00:00:25,200
This is why I highly recommend you to think about it and implement it in the best possible way.

7
00:00:28,540 --> 00:00:34,840
So first of all, he'll want to create a class and let's name it, employee, and now as it said, we

8
00:00:34,840 --> 00:00:37,840
need to have a constructor with the ID and name inside.

9
00:00:38,200 --> 00:00:43,660
This is why let's create a constructor and we're getting our age and name and after this were signed

10
00:00:43,660 --> 00:00:44,530
them to this.

11
00:00:45,130 --> 00:00:48,760
Here is our ID, and this name equals name.

12
00:00:49,000 --> 00:00:53,740
So we're getting these two properties, but you can do it better because you must show that you're a

13
00:00:53,740 --> 00:00:54,490
good developer.

14
00:00:54,730 --> 00:00:58,900
This is why it is really nice to check if we're past inside these two properties.

15
00:00:59,080 --> 00:01:05,380
So we can just tell, OK, if we didn't pass ID or we didn't pass name, then we want to throw in there.

16
00:01:05,860 --> 00:01:10,180
This is why I want to throw here New ERA and here inside we can write.

17
00:01:10,180 --> 00:01:17,740
For example, our employee I.D. and name are mandatory because actually this is what it is seen in the

18
00:01:17,740 --> 00:01:20,320
task, and it is nice to cover this feature.

19
00:01:20,590 --> 00:01:25,810
Also, as you can see, we have a line and it has a sell at a property, which actually means we can

20
00:01:25,810 --> 00:01:27,010
set the salary.

21
00:01:27,160 --> 00:01:32,650
It's not like we're getting it in constructor, so we need to Serta and get the functions for our salary.

22
00:01:32,830 --> 00:01:39,010
So first of all, we can define it set salary and it will be a function of a center for salary and we

23
00:01:39,070 --> 00:01:43,020
passing inside our salary and we just store it inside this.

24
00:01:43,030 --> 00:01:46,270
So this Dot's salary equals our salary.

25
00:01:46,660 --> 00:01:49,090
This is not all because we also want to get.

26
00:01:49,300 --> 00:01:55,420
Yes, sure, the salary is available inside our class, but we really want to construct this class in

27
00:01:55,420 --> 00:02:01,510
advanced way, which actually means we want to have some public API and some methods to get our properties.

28
00:02:01,810 --> 00:02:07,960
This is why here I highly recommend it to create get salary and we don't need anything here and we want

29
00:02:07,960 --> 00:02:08,920
to return here.

30
00:02:08,980 --> 00:02:14,410
This dot salary, and it also makes sense to create together for our ad and name.

31
00:02:14,620 --> 00:02:21,370
So here we can create get the method and inside were written in our thesis dot idea and we also can

32
00:02:21,370 --> 00:02:25,660
create here, get named method and it will return our thesis name.

33
00:02:25,840 --> 00:02:31,540
So as you can see, we thought quite a lot about our class and it is implemented as best as we can.

34
00:02:31,870 --> 00:02:33,670
Now here we can try to use it.

35
00:02:33,790 --> 00:02:40,270
So here we are, creating our employee with new employee and we are passing inside ID and name because

36
00:02:40,270 --> 00:02:42,570
they are mandatory and actually we can check it.

37
00:02:42,580 --> 00:02:47,050
We can rely on the page and we are getting employee I.D. and name are mandatory.

38
00:02:47,170 --> 00:02:48,520
And this is nice to check.

39
00:02:48,730 --> 00:02:50,920
So here is our eighty-one and name.

40
00:02:50,930 --> 00:02:55,930
For example, check and now our employee bond through a narrow what we can do now.

41
00:02:55,930 --> 00:03:01,750
We can write employee said salary and work bison, for example, one thousand inside and now we can

42
00:03:01,750 --> 00:03:02,140
check it.

43
00:03:02,140 --> 00:03:08,170
So I will rely on the page and here is our employee with their name and salary, but will also have

44
00:03:08,170 --> 00:03:08,710
a get us.

45
00:03:08,710 --> 00:03:14,470
For example, get salary, will return to our salary and get name will return the name, which actually

46
00:03:14,470 --> 00:03:17,560
means we implemented our class as best as possible.

47
00:03:17,770 --> 00:03:24,190
But now get getting the second task design a class for manager, which is employee and can have a department

48
00:03:24,190 --> 00:03:30,430
property, which actually means here your interviewer want to see extend of our class because we can

49
00:03:30,430 --> 00:03:33,400
create in your class based on our employee class.

50
00:03:33,700 --> 00:03:35,110
This is way here on the bottom.

51
00:03:35,260 --> 00:03:37,510
We can create a new class manager.

52
00:03:37,690 --> 00:03:42,700
And here we want to use extends to take the functionality of our employee class.

53
00:03:43,030 --> 00:03:44,920
And actually, this is almost it.

54
00:03:45,190 --> 00:03:50,080
This will take everything from our employee class, but we also need to create a department.

55
00:03:50,320 --> 00:03:54,370
This is why we just need a center and a getter, just like we did previously.

56
00:03:54,580 --> 00:03:56,890
So let's create here, said Department.

57
00:03:57,100 --> 00:04:00,130
And here inside we are passing department or just name.

58
00:04:00,460 --> 00:04:02,560
And here we are, saving our name inside.

59
00:04:02,860 --> 00:04:09,250
We also need to get us, so get department and we don't need any arguments here and we want to return

60
00:04:09,270 --> 00:04:10,900
our Theaster department.

61
00:04:11,350 --> 00:04:16,570
And actually, it is also super important to have a nice name, several where, as you can see, I am

62
00:04:16,570 --> 00:04:20,140
not naming things like said or just at full or whatever.

63
00:04:20,350 --> 00:04:26,140
I really tried to make the names as production ready as possible by using here, for example, said

64
00:04:26,140 --> 00:04:27,580
department departments.

65
00:04:27,580 --> 00:04:33,130
So it is all clear what it is about, and it really shows on the interview that you are a good developer

66
00:04:33,310 --> 00:04:35,380
and you can write high quality code.

67
00:04:35,920 --> 00:04:38,440
So here we have our said department and get department.

68
00:04:38,620 --> 00:04:40,240
Now let's create our manager.

69
00:04:40,480 --> 00:04:46,510
So we're just creating human nature and we must pass inside as always, idea and name, for example,

70
00:04:46,510 --> 00:04:46,870
John.

71
00:04:47,110 --> 00:04:53,590
And now here we can check our manager so we can make said department and wear person inside department,

72
00:04:53,590 --> 00:04:55,060
for example development.

73
00:04:55,570 --> 00:04:57,520
And now we can check our manager.

74
00:04:57,550 --> 00:05:02,920
So we haven't said department and there is a GED department function, which will return fire at the

75
00:05:02,920 --> 00:05:03,460
department.

76
00:05:03,940 --> 00:05:09,160
This is how typically you will answer questions regarding classes or extension of the classes.
