1
00:00:00,730 --> 00:00:08,510
Hire everyone in this theater all I'm going to go ahead and talk about using methods and objects together.

2
00:00:08,530 --> 00:00:09,130
OK.

3
00:00:09,370 --> 00:00:12,620
So first we need to create a Java project.

4
00:00:12,790 --> 00:00:19,550
So in order to create a Java project we need to click on this file new and then click on Java project.

5
00:00:19,570 --> 00:00:20,040
OK.

6
00:00:20,080 --> 00:00:28,190
So for the project name just type in here objects and methods.

7
00:00:28,300 --> 00:00:31,740
So as you can see here our project is now created.

8
00:00:31,750 --> 00:00:34,970
So first we need our class for our project.

9
00:00:35,140 --> 00:00:37,370
So just click on this as RC for that.

10
00:00:37,390 --> 00:00:45,610
Or you can click on these objects and methods project and then click on file name and click on class.

11
00:00:45,610 --> 00:00:52,960
So here for the class name just type in here Main and for the package name we need a reverse domain

12
00:00:52,960 --> 00:00:53,440
here.

13
00:00:53,440 --> 00:00:58,850
So I typed in here com that's my name and find out the project is public.

14
00:00:59,110 --> 00:01:06,010
And here make sure that you check this checkbox that says public static void main if it OK and then

15
00:01:06,010 --> 00:01:07,330
click on finish.

16
00:01:07,870 --> 00:01:11,640
So as you can see here our class is now created.

17
00:01:11,770 --> 00:01:15,270
So first let me actually delete this comment here.

18
00:01:15,670 --> 00:01:21,280
And then in order to make this a little earlier Vider I just need to double click undismayed that job

19
00:01:21,280 --> 00:01:22,650
I have here.

20
00:01:22,660 --> 00:01:26,020
So as you can see here our editor area is now much wider.

21
00:01:26,020 --> 00:01:29,450
And then we can actually write our coats in this method.

22
00:01:29,460 --> 00:01:29,770
OK.

23
00:01:29,770 --> 00:01:31,030
In this main method.

24
00:01:31,030 --> 00:01:35,030
So this main effect is the starting point for actually running.

25
00:01:35,080 --> 00:01:36,200
Our job coats.

26
00:01:36,220 --> 00:01:36,840
Okay.

27
00:01:37,030 --> 00:01:37,630
Okay.

28
00:01:37,810 --> 00:01:41,700
So first of all I want to create an object.

29
00:01:41,710 --> 00:01:42,430
Okay.

30
00:01:42,760 --> 00:01:51,400
So in order to create an object you need to have a blueprint in order to show me exactly how to create

31
00:01:51,850 --> 00:01:52,400
an object.

32
00:01:52,420 --> 00:01:53,030
OK.

33
00:01:53,320 --> 00:02:02,390
So in Java in order to have a blueprint for showing us how to create an object we need to create a class.

34
00:02:02,500 --> 00:02:03,000
OK.

35
00:02:03,130 --> 00:02:05,500
So our class is like a blueprint in Java.

36
00:02:05,500 --> 00:02:06,250
OK.

37
00:02:06,400 --> 00:02:09,350
So let's first create a class called liar.

38
00:02:09,550 --> 00:02:10,160
OK.

39
00:02:10,420 --> 00:02:16,140
So in order to create a class of we just need to click on this package here.

40
00:02:16,300 --> 00:02:17,030
OK.

41
00:02:17,410 --> 00:02:22,230
And then we need to click on File knew and then click on class.

42
00:02:22,240 --> 00:02:25,140
So for the class name just type in here line.

43
00:02:25,750 --> 00:02:30,220
And as you can see here it's going to actually put our class inside this package.

44
00:02:30,220 --> 00:02:30,680
OK.

45
00:02:30,700 --> 00:02:34,070
So that's why we actually clicked on this package.

46
00:02:34,150 --> 00:02:36,210
And then we started to create a class.

47
00:02:36,220 --> 00:02:36,780
OK.

48
00:02:36,820 --> 00:02:39,050
So for the modifiers the public.

49
00:02:39,190 --> 00:02:41,760
And then click on finish.

50
00:02:41,830 --> 00:02:45,250
So as you can see here our class is now created.

51
00:02:45,430 --> 00:02:51,520
OK now we need to actually put some instructions inside this class in order to actually show us how

52
00:02:51,520 --> 00:02:53,420
to create life and objects.

53
00:02:53,440 --> 00:02:54,160
OK.

54
00:02:54,160 --> 00:03:00,480
So as you can see here now that our client class is created we have our blueprint.

55
00:03:00,760 --> 00:03:01,280
OK.

56
00:03:01,450 --> 00:03:08,500
But there are no instructions in this blueprint in order to show us exactly what are the characteristics

57
00:03:08,800 --> 00:03:10,620
and behaviors of a lawyer.

58
00:03:10,770 --> 00:03:15,480
OK so now we can put some instructions inside this blueprint.

59
00:03:15,730 --> 00:03:20,300
So first I want to put the characteristics of a lion inside this class.

60
00:03:20,320 --> 00:03:20,930
OK.

61
00:03:21,250 --> 00:03:27,790
So the characteristics of a lion are for example and speed.

62
00:03:28,390 --> 00:03:32,980
And then I can assign a value to this variable for example number 90.

63
00:03:33,340 --> 00:03:34,060
OK.

64
00:03:34,340 --> 00:03:39,970
Int power for example 100.

65
00:03:40,270 --> 00:03:40,860
OK.

66
00:03:40,990 --> 00:03:43,250
So these are the characteristics of a liar.

67
00:03:43,300 --> 00:03:44,050
OK.

68
00:03:44,050 --> 00:03:47,620
Now you want to specify the behaviors of a lion.

69
00:03:47,620 --> 00:03:52,530
So for example the behaviors of a lion are for example a lion roll.

70
00:03:52,540 --> 00:03:53,110
OK.

71
00:03:53,290 --> 00:03:59,340
So in order to show their behaviors of an object we need to create Misfit's.

72
00:03:59,380 --> 00:04:04,470
So in order to show how my lawyer rolls we need to create a method.

73
00:04:04,660 --> 00:04:09,620
So I just let you type in here void and the name of my method is wrong.

74
00:04:09,960 --> 00:04:10,660
OK.

75
00:04:10,960 --> 00:04:15,330
And then I need to put in a pair of round brackets after my Meffert name.

76
00:04:15,520 --> 00:04:21,590
And then I need to open and close my Meffert by using an opening curly brace followed by our closing

77
00:04:21,610 --> 00:04:22,170
calibrates.

78
00:04:22,180 --> 00:04:22,650
OK.

79
00:04:22,780 --> 00:04:24,130
And then inside is left.

80
00:04:24,160 --> 00:04:26,260
I can put in my statements.

81
00:04:26,260 --> 00:04:29,840
So now you want to show how my lane roads.

82
00:04:30,040 --> 00:04:38,520
So I just made you type in here system that's out that pretty learn and an inside Apprentice's I put

83
00:04:38,530 --> 00:04:41,800
in two double quotes and the inside double quotes.

84
00:04:41,810 --> 00:04:43,470
I just tried roll

85
00:04:46,370 --> 00:04:50,070
and then at the end of my statement I need to put in a semi-colon.

86
00:04:50,420 --> 00:04:56,510
So this is how my lawyer was OK or for example El-Aurian runs OK.

87
00:04:56,750 --> 00:05:04,060
So I just need to type in here Voyt run and then I need to put in a pair of round brackets after my

88
00:05:04,320 --> 00:05:04,830
name.

89
00:05:05,060 --> 00:05:12,230
And then I need to open and close my fit by using an opening curly brace followed by our closing curly

90
00:05:12,230 --> 00:05:17,240
brace and then inside I'm afraid I can put my statements.

91
00:05:17,240 --> 00:05:19,250
So I just type in here system

92
00:05:21,920 --> 00:05:30,500
out that Princeton and then inside the apprentice's I can just put into double quotes and here I write

93
00:05:31,460 --> 00:05:34,460
run.

94
00:05:34,480 --> 00:05:36,770
So this is how my lion runs.

95
00:05:36,790 --> 00:05:37,420
OK.

96
00:05:37,480 --> 00:05:39,980
Or for example my lion fights.

97
00:05:40,000 --> 00:05:40,570
OK.

98
00:05:40,780 --> 00:05:42,200
So I just let you type in here.

99
00:05:42,230 --> 00:05:44,760
Voyt fight.

100
00:05:45,430 --> 00:05:52,000
And then I need to put in a pair of round brackets and then I need to open and close my left and then

101
00:05:52,000 --> 00:05:55,140
inside the Smurfette I can just put in my statements.

102
00:05:55,150 --> 00:06:03,250
So I just type in your system that out that Priestland and that inside the prentices I put into double

103
00:06:03,250 --> 00:06:07,610
coats and that inside the double quotes I right fight

104
00:06:11,170 --> 00:06:19,390
thought this is how my lion fights OK or for example my lion sleeps.

105
00:06:19,440 --> 00:06:21,990
So again I can just I've been here voit.

106
00:06:22,260 --> 00:06:27,970
So as you can see here the return type of mine if it is void my method is going to return nothing.

107
00:06:28,050 --> 00:06:28,720
OK.

108
00:06:28,920 --> 00:06:30,470
It's just going to actually do something.

109
00:06:30,510 --> 00:06:31,280
OK.

110
00:06:31,650 --> 00:06:39,160
And the name of my method is sleep and then I need to put in a pair of round brackets after them if

111
00:06:39,150 --> 00:06:39,850
at any.

112
00:06:40,230 --> 00:06:45,750
And then I need to open and close my Minford by using these curly braces as you can see here.

113
00:06:46,260 --> 00:06:49,830
And that inside this method I can put in my statements.

114
00:06:50,040 --> 00:06:55,560
So I just type in here system that out that princeling.

115
00:06:56,010 --> 00:07:02,090
And then inside the prentices I can't just put into double coats and then inside the double quotes.

116
00:07:02,370 --> 00:07:09,750
I just right sleep so this is how my lion sleeps.

117
00:07:09,760 --> 00:07:10,330
OK.

118
00:07:10,570 --> 00:07:17,700
So now that's my blueprint is ready we can actually create loyal objects from this class.

119
00:07:17,710 --> 00:07:18,730
OK.

120
00:07:18,730 --> 00:07:24,330
So inside the main class and then inside the main Mfat I can create an object.

121
00:07:24,340 --> 00:07:29,610
So first of all I need to refer to the name of my class line.

122
00:07:30,610 --> 00:07:31,480
OK.

123
00:07:31,870 --> 00:07:35,630
And the name of my object is my lawyer.

124
00:07:36,130 --> 00:07:43,710
And that I need to between an assignment operator here and then I put in this key vote new.

125
00:07:44,140 --> 00:07:45,060
OK.

126
00:07:45,610 --> 00:07:53,200
And then again I need to refer to the name of my class and then I need to put in a pair of round brackets

127
00:07:53,260 --> 00:07:54,320
after my class.

128
00:07:54,400 --> 00:07:55,060
OK.

129
00:07:55,390 --> 00:08:00,590
And then I need to put a semi-colon at the end of my statements.

130
00:08:00,610 --> 00:08:08,180
So as you can see here first of all I referred to the name of my class line and I gave my object a name.

131
00:08:08,470 --> 00:08:09,060
OK.

132
00:08:09,430 --> 00:08:12,150
And then I put an assignment operator here.

133
00:08:12,550 --> 00:08:15,560
And then I put this key vote here knew.

134
00:08:15,780 --> 00:08:22,420
OK so here we are actually telling the computer that if you are going to actually create a new object

135
00:08:22,840 --> 00:08:24,320
from this loincloths.

136
00:08:24,340 --> 00:08:25,100
OK.

137
00:08:25,420 --> 00:08:29,070
So that's the job of this new Q-Bot here.

138
00:08:29,470 --> 00:08:34,820
And then you are actually telling Dad we are going to create a new object from this class.

139
00:08:34,840 --> 00:08:35,210
OK.

140
00:08:35,230 --> 00:08:41,020
So first of all you are actually referring to the name of our class and then we are actually giving

141
00:08:41,110 --> 00:08:48,830
our object a name and then we use this assignment operator and then we're actually instantiating our

142
00:08:48,940 --> 00:08:49,340
object.

143
00:08:49,350 --> 00:08:50,030
OK.

144
00:08:50,080 --> 00:08:53,980
You are actually creating a new object from this class.

145
00:08:53,980 --> 00:08:59,270
So as you can see here our object is now created inside a memory.

146
00:08:59,290 --> 00:09:06,340
So now in order to show you how my object is created and what is the address of my object inside the

147
00:09:06,340 --> 00:09:06,930
memory.

148
00:09:07,090 --> 00:09:15,550
I just need to type in here system that out that learn and then inside the apprentice's I can just refer

149
00:09:15,550 --> 00:09:17,710
to the name of my object my lawyer.

150
00:09:17,800 --> 00:09:21,080
And then at the end of my statement I need to put in a semicolon.

151
00:09:21,400 --> 00:09:27,940
So now if I run on my project as you can see this is the address of my lawyer an object inside the memory.

152
00:09:27,940 --> 00:09:34,030
Ok this is just a way to show you that our object is actually created inside a memory.

153
00:09:34,030 --> 00:09:34,730
OK.

154
00:09:34,780 --> 00:09:39,130
And this is the address of this my client object inside the memory OK.

