ok so let's take the next step on one of the ideas
on that we get that we had when we implemented this model you
controller was that we can catch multiple use to the same model
and all of them automatically get updated
through z observatiton through the observer so
now we're going to yeah use the benefits of the observer pattern
to implement this behavior exactly so
you still i hope so at least you remember the account
of you that that we had and we didn't change anything here
so we have this strike at that's what we add that
was the last thing that we added because we we do this on
typecasting here which could go wrong because no objects this
typecasting explicit occurs which could go wrong because the
object doesn't always need to be something that
can be cast into an integer and arm so what we do know as we
just add a couple of new use so we had the tiny little rectangle
which moves along the screen yet and now we want to move have
another rectangle for example that change the color exactly
and we prepared a little bit here so on
you don't have to wait until he slowly tried everything in
the exact so it does basically the same so it
register as the if you with the subject
so calls the on the observed that the super the
construct of the superclass the of the observe
extend also extends the observer on and then we just kind of
have a new array of colors here and then we cast again because
the value into an end and then we just go through
the array is or not be we define and use
we define a new color for for each element
and then on we kind of an and use them as the the the red green
and blue all factors and feel direct ending with these
countries cobb that kind of this created from these three components
and then we we draw we re draw the same thing
as before nothing new in and then another third
one which is displayed a number of arm and in this case it's
little different because here for example
we can use a string there because
we need a string in the end to display the number
so we need also to kind of make this object that we pass in
into a string and the easiest way to make something to string
is to chose at an empty space again with what we will know
we'll call internally to string on the object
and then add an empty in active string and
which does nothing and yeah and in
line number ten we update was a string already given doesn't
that interview with the other
methods like in kind of color all condom you
know i mean because this update method is an object object
is fine and the only place where it would cause
problem is where we do the typecasting and we don't do attack
us in the same as of this date only cords
this update in this class so therefore and basically it
might also be would also work like this
because then the the integer would be turned to string in
the same way than any other so
what do we need to do we need to say that first
then we need to consecrate or them use and
here we need to register them was our model
but this is automatically done
more or less and less so let's start with the so we create
the references first opened of you cum and
continue number and all of these are still observance
and now we fifty clear or references now we need to assigns
values so we need to court constructors and this is also kind
of a basic concept in using these design that
answers try to use the interface wherever possible
because polymorphism is going to
ok so that's that now
we can control a good so you can digital use
so cooking pasting is normally hedley discouraged
but as well but you know
and now we need to we need to for the correct
constructions so lower case
and please do recall that the court has a constructor already
registers the object with the model exactly so the model is
fast here the car this past year so that the can you use get
registered with the model so that should modest speed is sufficient
so let's riots
and there is nothing to see it there's a counter
onto with where the slow that's normally in the beginning so
nodes and warm up well the other things are missing
yes your crash no and in there must be
let's try to try one so within here at the number
yeah let let's let's that stretches to two species wrong
and is color or what we see here yeah still going up yes here
we go on color or causes where numbers are
the numbers are gone let's have a look in two
to use yeah you see
it's this line so when the crawl method or when this is read
from it does was yeah methods
he acted method has a quarter background tended not only draws
the number or the rectangular but also the complete background
all over and so yet first thing that had this everything is
painted great and then the moving on after rectangle
all the number although call-ups rectangle storm
on top of that and then everything is kind of trade again and
only the nothing sorites so so how do we have that we remove
that here but we will need to have its own so
we that's let's just see what happens if removed everywhere
and we have not probably know back on the movement
so that maybe i didn't like that great
you pick sometimes ok what happens
yeah i would like to know all along with great
for her paine's everything all over again and that's a moving
on this moving on and look it kind of leaves a trail pheromone
so i'm going to stop you know
yeah we need as a we need to background that's what we want
to show the and we needed just once for every frame
yeah so we do that in the most clicked
and of course that this big project would be we
in the in the key had this so you have that so
we can just quite background because this is where we are
ok now let's try it again but we haven't
all over each other still but now
yeah i mean that's that's problem if you put everything in
the same place that it's a little each other but
it is actually const correctly so that is
covered by first number was cover and there's also the little
rectangle moving the little moving rectangle you see it doesn't
leave trail anymore so basically you're still trying to get
into the and variety