WEBVTT

0
00:00.540 --> 00:04.530
The objective is we want to be able to build a turtle race,

1
00:04.860 --> 00:09.860
where we have multiple turtles to run along a line and then see who actually

2
00:10.860 --> 00:14.400
reaches the finish line first. Now here's a question though.

3
00:14.970 --> 00:18.660
We know how to build one turtle from the turtle blueprint,

4
00:18.930 --> 00:23.130
but what if we need more turtles? How do we get hold of them?

5
00:23.490 --> 00:24.210
Well,

6
00:24.210 --> 00:29.210
we know that we can use a class or a blueprint to define what a turtle should

7
00:31.950 --> 00:34.350
appear like and how it should behave.

8
00:34.710 --> 00:37.830
So what it has and what it can do. Now,

9
00:37.830 --> 00:42.830
we can then take this class and construct an actual turtle object from it

10
00:43.470 --> 00:46.980
which is then doing all the drawing and walking around on the screen.

11
00:47.430 --> 00:51.900
So this is what the code has looked like so far. We have Timmy

12
00:51.960 --> 00:56.960
which is our turtle object, and turtle coming from the turtle module is the

13
00:57.330 --> 01:00.060
class which is used to construct this object.

14
01:00.420 --> 01:05.420
But that's not the end of the story because the whole reason why we can have

15
01:06.120 --> 01:10.440
these blueprints is so we can make more objects.

16
01:10.830 --> 01:15.060
So, we're not limited to just one turtle object.

17
01:15.090 --> 01:19.980
We can create as many as we need in the same way that we have created Timmy.

18
01:20.220 --> 01:23.910
We create Tommy, Johnny, Jenny, and Benny.

19
01:24.840 --> 01:28.890
Even though both Timmy and Tommy are turtle objects,

20
01:29.130 --> 01:32.610
they actually function completely independent of each other.

21
01:32.940 --> 01:37.920
So in programming, we would say that they are each a separate instance.

22
01:38.100 --> 01:39.750
So what does that mean? Well,

23
01:39.750 --> 01:43.830
that means that they're each an example of the turtle object.

24
01:44.160 --> 01:48.810
So just as you and I are both examples of human objects,

25
01:48.930 --> 01:52.140
Timmy and Tommy are both examples of turtle objects.

26
01:52.650 --> 01:55.020
And that means that at any moment in time,

27
01:55.140 --> 01:59.070
they could have different attributes and they could be doing different things.

28
01:59.730 --> 02:01.260
So that means, for example,

29
02:01.290 --> 02:06.290
Timmy could have his color set to green while Tommy could have its color set to

30
02:06.960 --> 02:09.360
something completely different, like purple.

31
02:09.750 --> 02:14.750
Now the fact that each of these objects can have different attributes and can be

32
02:16.050 --> 02:21.050
performing different methods at any one time in programming is known as their

33
02:21.660 --> 02:22.493
state.

34
02:23.070 --> 02:28.070
So the state of Timmy's color attribute is green and Tommy's color attribute is

35
02:29.370 --> 02:31.260
purple. So in this case,

36
02:31.290 --> 02:35.970
they have different state in terms of their attribute or their appearance.

37
02:36.510 --> 02:39.780
But they can also have different state in terms of whether

38
02:39.780 --> 02:42.780
if they are doing something. For example,

39
02:42.810 --> 02:47.810
Timmy could be asked to move forwards while Tommy is staying completely

40
02:48.750 --> 02:51.900
stationary. So Timmy is in the middle of a method call

41
02:51.930 --> 02:56.340
whereas Tommy is not doing anything at all. Now in the next lesson,

42
02:56.370 --> 02:59.200
we're going to be building out our turtle racing game

43
02:59.620 --> 03:01.360
and we're going to see this in action.

44
03:01.540 --> 03:06.540
The idea that you could have separate versions of the same object each with a

45
03:07.480 --> 03:12.480
different state and acting completely independently from each other in order to

46
03:13.600 --> 03:17.560
race against each other. So don't worry if this doesn't make sense

47
03:17.560 --> 03:20.440
a hundred percent just yet. Head over to the next lesson

48
03:20.740 --> 03:24.190
and we're going to start writing some real code to better understand this

49
03:24.190 --> 03:24.850
concept.