WEBVTT

1
00:00:00.090 --> 00:00:04.910
ok so let's take the next
step on one of the ideas

2
00:00:04.920 --> 00:00:09.320
on that we get that we had when
we implemented this model you

3
00:00:09.320 --> 00:00:14.230
controller was that we can catch
multiple use to the same model

4
00:00:14.330 --> 00:00:17.630
and all of them
automatically get updated

5
00:00:18.110 --> 00:00:20.470
through z observatiton
through the observer so

6
00:00:20.990 --> 00:00:25.580
now we're going to yeah use the
benefits of the observer pattern

7
00:00:25.590 --> 00:00:30.750
to implement this
behavior exactly so

8
00:00:31.090 --> 00:00:34.490
you still i hope so at least
 you remember the account

9
00:00:34.490 --> 00:00:37.770
of you that that we had and we
didn't change anything here

10
00:00:37.980 --> 00:00:42.030
so we have this strike at
that's what we add that

11
00:00:42.030 --> 00:00:45.650
was the last thing that we added
 because we we do this on

12
00:00:46.460 --> 00:00:50.170
typecasting here which could go
wrong because no objects this

13
00:00:50.200 --> 00:00:54.100
typecasting explicit occurs which
 could go wrong because the

14
00:00:54.100 --> 00:00:58.710
object doesn't always need
 to be something that

15
00:00:58.710 --> 00:01:06.360
can be cast into an integer and
arm so what we do know as we

16
00:01:06.370 --> 00:01:12.080
just add a couple of new use so we
 had the tiny little rectangle

17
00:01:12.080 --> 00:01:15.930
which moves along the screen yet
 and now we want to move have

18
00:01:15.930 --> 00:01:19.560
another rectangle for example
that change the color exactly

19
00:01:19.560 --> 00:01:22.190
and we prepared a
little bit here so on

20
00:01:23.180 --> 00:01:25.820
you don't have to wait until he
 slowly tried everything in

21
00:01:25.920 --> 00:01:30.280
the exact so it does
basically the same so it

22
00:01:30.280 --> 00:01:33.960
register as the if you
 with the subject

23
00:01:34.270 --> 00:01:38.570
so calls the on the observed
 that the super the

24
00:01:38.580 --> 00:01:42.100
construct of the superclass
 the of the observe

25
00:01:42.410 --> 00:01:47.500
extend also extends the observer
 on and then we just kind of

26
00:01:48.010 --> 00:01:52.820
have a new array of colors here
and then we cast again because

27
00:01:52.820 --> 00:01:56.940
the value into an end and
then we just go through

28
00:01:56.940 --> 00:02:02.020
the array is or not be
 we define and use

29
00:02:02.050 --> 00:02:05.150
we define a new color
for for each element

30
00:02:05.320 --> 00:02:10.500
and then on we kind of an and use
 them as the the the red green

31
00:02:10.500 --> 00:02:15.290
and blue all factors and feel
 direct ending with these

32
00:02:15.590 --> 00:02:19.670
countries cobb that kind of this
created from these three components

33
00:02:19.680 --> 00:02:22.890
and then we we draw we
re draw the same thing

34
00:02:23.270 --> 00:02:27.620
as before nothing new in
and then another third

35
00:02:27.620 --> 00:02:33.510
one which is displayed a number
of arm and in this case it's

36
00:02:33.510 --> 00:02:36.960
little different because
 here for example

37
00:02:37.260 --> 00:02:41.550
we can use a string
 there because

38
00:02:41.560 --> 00:02:45.040
we need a string in the end
 to display the number

39
00:02:45.050 --> 00:02:50.600
so we need also to kind of make
 this object that we pass in

40
00:02:50.610 --> 00:02:55.820
into a string and the easiest way
 to make something to string

41
00:02:55.830 --> 00:03:00.060
is to chose at an empty space
again with what we will know

42
00:03:00.070 --> 00:03:03.630
we'll call internally to
 string on the object

43
00:03:04.210 --> 00:03:07.780
and then add an empty
in active string and

44
00:03:08.200 --> 00:03:12.280
which does nothing
and yeah and in

45
00:03:12.280 --> 00:03:15.490
line number ten we update was a
string already given doesn't

46
00:03:15.490 --> 00:03:17.250
that interview
with the other

47
00:03:18.190 --> 00:03:21.570
methods like in kind of
color all condom you

48
00:03:21.750 --> 00:03:25.740
know i mean because this update
 method is an object object

49
00:03:25.740 --> 00:03:30.260
is fine and the only place
 where it would cause

50
00:03:30.270 --> 00:03:34.030
problem is where we do the
typecasting and we don't do attack

51
00:03:34.030 --> 00:03:37.180
us in the same as of
this date only cords

52
00:03:37.340 --> 00:03:41.090
this update in this class so
therefore and basically it

53
00:03:42.130 --> 00:03:44.410
might also be would
also work like this

54
00:03:44.610 --> 00:03:48.600
because then the the integer
would be turned to string in

55
00:03:48.810 --> 00:03:52.220
the same way than
 any other so

56
00:03:55.030 --> 00:03:57.020
what do we need to do we
need to say that first

57
00:03:57.480 --> 00:04:01.370
then we need to consecrate
 or them use and

58
00:04:01.660 --> 00:04:05.540
here we need to register
 them was our model

59
00:04:05.890 --> 00:04:08.290
but this is
automatically done

60
00:04:09.190 --> 00:04:14.390
more or less and less so let's
start with the so we create

61
00:04:14.410 --> 00:04:19.150
the references first
opened of you cum and

62
00:04:19.150 --> 00:04:23.450
continue number and all of
these are still observance

63
00:04:24.460 --> 00:04:29.240
and now we fifty clear or
references now we need to assigns

64
00:04:29.270 --> 00:04:32.610
values so we need to court
constructors and this is also kind

65
00:04:32.610 --> 00:04:36.320
of a basic concept in
using these design that

66
00:04:36.320 --> 00:04:40.390
answers try to use the
interface wherever possible

67
00:04:40.710 --> 00:04:44.520
because polymorphism
 is going to

68
00:04:44.690 --> 00:04:49.080
ok so that's that now

69
00:04:49.080 --> 00:04:52.570
we can control a good so
 you can digital use

70
00:04:53.250 --> 00:04:57.080
so cooking pasting is
normally hedley discouraged

71
00:04:59.920 --> 00:05:02.510
but as well
but you know

72
00:05:06.200 --> 00:05:09.910
and now we need to we
need to for the correct

73
00:05:10.090 --> 00:05:15.760
constructions
so lower case

74
00:05:20.750 --> 00:05:24.430
and please do recall that the
court has a constructor already

75
00:05:24.430 --> 00:05:29.720
registers the object with the
model exactly so the model is

76
00:05:29.720 --> 00:05:34.660
fast here the car this past year
 so that the can you use get

77
00:05:34.660 --> 00:05:40.410
registered with the model so that
should modest speed is sufficient

78
00:05:41.410 --> 00:05:42.450
so let's riots

79
00:05:45.210 --> 00:05:49.720
and there is nothing to
see it there's a counter

80
00:05:50.190 --> 00:05:54.810
onto with where the slow that's
normally in the beginning so

81
00:05:54.810 --> 00:06:00.830
nodes and warm up well the
other things are missing

82
00:06:00.840 --> 00:06:06.110
yes your crash no and
 in there must be

83
00:06:06.120 --> 00:06:09.520
let's try to try one so
within here at the number

84
00:06:10.080 --> 00:06:14.590
yeah let let's let's that
stretches to two species wrong

85
00:06:15.750 --> 00:06:26.610
and is color or what we see here
 yeah still going up yes here

86
00:06:26.610 --> 00:06:30.910
we go on color or causes
 where numbers are

87
00:06:31.660 --> 00:06:37.230
the numbers are gone let's
 have a look in two

88
00:06:37.240 --> 00:06:40.690
to use yeah you see

89
00:06:42.190 --> 00:06:47.690
it's this line so when the crawl
 method or when this is read

90
00:06:47.690 --> 00:06:50.440
from it does was
 yeah methods

91
00:06:51.030 --> 00:06:55.560
he acted method has a quarter
background tended not only draws

92
00:06:55.560 --> 00:06:58.610
the number or the rectangular but
 also the complete background

93
00:06:58.610 --> 00:07:02.230
all over and so yet first thing
 that had this everything is

94
00:07:02.230 --> 00:07:07.330
painted great and then the
moving on after rectangle

95
00:07:07.330 --> 00:07:10.940
all the number although
call-ups rectangle storm

96
00:07:10.940 --> 00:07:14.020
on top of that and then everything
 is kind of trade again and

97
00:07:14.030 --> 00:07:17.960
only the nothing sorites so so
how do we have that we remove

98
00:07:17.960 --> 00:07:20.790
that here but we will
need to have its own so

99
00:07:20.790 --> 00:07:24.680
we that's let's just see what
happens if removed everywhere

100
00:07:25.270 --> 00:07:29.960
and we have not probably
know back on the movement

101
00:07:29.960 --> 00:07:34.290
so that maybe i didn't
 like that great

102
00:07:37.920 --> 00:07:41.730
you pick sometimes
ok what happens

103
00:07:41.860 --> 00:07:45.840
yeah i would like to know
 all along with great

104
00:07:45.860 --> 00:07:50.320
for her paine's everything all
over again and that's a moving

105
00:07:50.370 --> 00:07:53.990
on this moving on and look it kind
 of leaves a trail pheromone

106
00:07:54.780 --> 00:07:55.980
so i'm going to
stop you know

107
00:07:58.210 --> 00:08:01.140
yeah we need as a we need to
background that's what we want

108
00:08:01.150 --> 00:08:06.530
to show the and we needed
just once for every frame

109
00:08:06.860 --> 00:08:09.670
yeah so we do that in
 the most clicked

110
00:08:16.680 --> 00:08:19.680
and of course that this
big project would be we

111
00:08:19.690 --> 00:08:24.080
in the in the key had this
 so you have that so

112
00:08:24.080 --> 00:08:27.860
we can just quite background
because this is where we are

113
00:08:28.110 --> 00:08:31.780
ok now let's try it
again but we haven't

114
00:08:32.370 --> 00:08:35.700
all over each other
 still but now

115
00:08:38.380 --> 00:08:41.190
yeah i mean that's that's problem
 if you put everything in

116
00:08:41.190 --> 00:08:43.770
the same place that it's
a little each other but

117
00:08:44.120 --> 00:08:47.090
it is actually const
correctly so that is

118
00:08:47.420 --> 00:08:51.040
covered by first number was cover
 and there's also the little

119
00:08:51.050 --> 00:08:54.250
rectangle moving the little moving
 rectangle you see it doesn't

120
00:08:54.250 --> 00:08:58.970
leave trail anymore so basically
 you're still trying to get

121
00:08:59.140 --> 00:09:00.250
into the and variety

