Welcome back.
I hope that you have successfully managed to solve these problem, right, so this challenge so if you
did, then you can skip this lecture or you can straight look in the final version and see if you have
done a good job.
Now, there is a no right answer, meaning that everyone can fix or they do these challenge differently.
So my approach today will be a little bit different.
I'm going to open the best code here.
So what I'm going to do, I just want to speed up a little bit things.
So I'm going to open the folder and I'm going to open the starter file.
Right.
So if you start a file, I do have this index with its own styling.
So there is a inline styling.
I don't have external Cyesis file.
Right.
But I do have these Gere's and Appalachia's, which is empty in this image that I use.
OK, now I'm going to go here, I'm going to open with live server.
Right, click open with live server and I'm just going to copy to you were l I'm going to open with
Google Chrome right now.
There you go.
Here, if you do inspect the console, log will be empty.
There is nothing there.
Right.
OK, so what I'm going to do actually, I'm going to close this one and I'm just going to open this
clinic parking challenge.
I'm going to go to the final one.
The is going to copy it and I'm going to put it here outside.
So I'm going to do this because.
Open fire.
I'm going to use this on desktop ears, so this is the Finnish version, so I'm just going to copy it.
And I'm going to put it here and I'm going to delete a couple of the things, but I'm just going to
make a starting point, right?
I'm just going to make a starting point.
Good.
Now, the data, we'll leave it there.
This function.
I really don't need I can create all of these functions and also this map method, this one.
So you can do it with me.
I want to have this.
I want to have the parent class, the parking, the clinical class.
I want to have the data, the clinical report.
Very good.
I want to have this one cut this cut that one make a little bit here.
And that's pretty much, you know why I want this, because that will save us a ton of time.
OK, so nothing will happen because we're not printing anything and we are calling here the reports.
OK, now go from top.
So my class as a parent or super class is a building class.
Why?
Because in the report are seeing here all of the clinics in parking have the building address in your.
So me that this is a perfect solution to find a parent class.
These class will actually be used here and extended by the parking and clinic.
Now we only have three classes, two will be subclasses in one class.
That's it for this project.
For this challenge.
That's enough.
So let's create a constructor here.
Now, the first thing I think first when the when a class is called is going to be called the constructor.
So I'm going to put here address in here built.
Right.
Good.
Now I'm going to see these addressed equal to the address we are passing through a contractor.
These here, Bill, equal to the bill.
We are passing through the constructor now for the parking.
The parking now can extend this by calling the super constructor.
So also the parking will have its own constructor.
But first, we need to address in here.
These are from the Supercoach program.
And after those side, we could just call the super constructor we address in your bill.
And that's it.
This is how we have done the habitants.
Now, this parking will have a couple of more things that we need to do.
We can say size here, size will be the full size for both all old parking and hourly parking spots.
And I'm going to see here fool spots.
Or at least parts.
Thrice hourly in food, the price, so this will be three dollars, nine dollars in here.
This depends on just how many we're going to pass it here.
Now you have this data.
Twenty, sixteen.
And the address come from the superclass.
This will be a one hundred and fifty the size.
We're not going to use this much.
We're not done.
But I'm just showing where this data is coming from.
This 90 and 60 will be 90 full.
All the parking spots and 60 will be hourly parking spots.
So if you combine these two, it will give you one hundred and fifty.
So I just you can you don't need to put the size, but I just want to be there.
Good.
Oh, what else?
I can just get rid of this for 09 here and we can have pretty much something similar.
Now, I'm just going to go back here.
We need to finish these stop signs equal to the size we are passing through a constructor does that
few spots equal to the full spots.
Let's finish this one.
This that hourly pass, it will be equal to hourlies, plus the stock price.
Hourly price hourly and this that food, the price equal to food, they for good.
Now, that is our parking class.
What about our cleaning class where our class will be smaller?
We will have, again, constructor.
We address from the superclass in here called Bill.
After that, we now say daily or we can say just patience.
Patience.
That's what a daily basis.
As it is in the final version, so daily basis and what else here I'm going to say sighs now decides
I'm not going to put anything in the size of the moment.
We need to call the super constructor first year bill, then these that daily is equal to the daily
basis and these that size equal to the size.
OK.
Now we are ready.
These are both of this clinic is extending the building class.
Right.
And that is what it makes the inheritance easy.
Good.
Now what we can do here, instead of writing a couple of new instances of a clearly class in a couple
of years to sort of a working class, I just realized that it will be easier if we put them as an error
in here.
I will create new four new clinics first.
It will have the address and the year that will come from the parent class.
Then one hundred and five will be the daily pages and the size will be three, then size will be three,
three, one and two.
So what is this one and two size.
OK, in our.
In our here in our report is simply excise could be small, normal and big.
So this is the best way to put a map.
So we need we need to use our new data structure that we learn.
That was map.
Right.
And I'm going to put zero as a small one is normal in solving one is a small two as a normal thing.
Three is a big.
So that is why I put one, two, three, because the map alone allows allowed us to create a separate
or custom data custom data type.
I mean custom.
We could put custom value there, for example.
It can mean Dejour string, it can be a boolean.
Right.
We learn about that.
Same goes for this.
This is the size, this is the full spot.
This is the hourly spot.
This is a price of three dollars per hour.
And this is the old parking space.
And these two are coming from the superclass, our parent class or the building.
Now, here, we're going to do the clinical report as he comes along.
And I'm going to put it like this Kleenex report.
OK, now copy this.
Make sure that you have one, one or two more.
So I'm just going to copy this and pasted on the other side.
Right.
And make sure that you copy this one based in on this one and see parking's.
Report.
So here we call these two external functions, but what I want I want each side to pack up the data
that we just created.
Right, good.
So if I refresh now, if I go back here, I will have clinics report here in the parking parking's report.
Good.
Now, what we will do next.
So I'm going to close this one because we don't need it anymore.
Now, first things first.
We need to decide what we need to print.
And we are just going to print this.
This we just going to deal with this number three here, three one, two in.
We're going to create a function in that function will be called from our clinical report.
And that is actually if you go back here, that is actually the last things.
So what I want to do actually at the moment, first I want to comes
the here comes a lot of the clinics and but I need to pass in the Senate so you can pass the same variable
here.
But I'm going to say clinics here.
So.
So you need to pass the area clinics in here, I'm going to say parking's.
Good.
So if comes I love the clinics, I will have the entire area here is of all the clinics.
So what I want to do is actually to create a function for seeing what is the size of this clinic.
So what I'm going to do, I'm going to say.
Here.
I'm going to say clinics, not for each.
I'm going to look through each and every clinic in the current element, so I'm going to use the error
function here.
And I'm going to say current that we haven't created this function yet.
Building, building, spec classification.
OK, so I'm going to call it from the current element.
I'm going to call this function what I'm calling from the current element.
Well, I just want to grab from each and every element.
This the last part, the last value, and that will be the size of the building.
OK, so I'm going to copy this and I'm going back to clinics in here.
We need to create dysfunction.
So how are we going to call this function the same as we did here?
Right.
So I'm going to say like that in here, inside, I'm going to say const wieneke size and that will be
equal to new map.
So I'm going to create an empty map.
So this was the perfect solution to create example.
To use hash maps.
Right.
Or our map.
Nice.
So I'm creating a new map.
So how we set the map.
So now we can see clinic size.
That set and I'm going to set one and I'm going to be small here.
So now you know why this is one, two and three, right?
So the first was the key.
The second was the value.
So I'm setting the value.
Two in three here.
You see here normal because that was our report.
Where was it so small, normal in big?
Now, you can see here small, small, small, normal and big in here, you can put small, small,
big, big, small, normal, for example, if you want to use strings so you can use whatever you want.
Now, here I just say Conjola, I'm going to use the template literals and I'm going to see these address.
Right,
plus built in
this year build and Colma is
Alesi clinic site.
So how we get the values using the get keyword in here.
I'm going to pass this size now and I'm going to say cleaning that.
Let's see what's happening now.
This one's history is a big clinic, is a big clinic, is a small clinic, is a normal clinic.
Good.
Now we access these year and the address from the parents of reclass and actually this is working.
But what if we don't have any any data here.
So undefined clinic, undefined, undefined.
So that's what we you we learned that we can use a default parameters and I'm going to say equal to
two.
And these always will be normal if we don't pass anything here.
Normal, normal, normal clinic.
Now you know how to use the default parameters.
Now we again repeat the Hashmat and I'm just going to return this back here.
I think it was three.
Three I think was one maybe or I'm not sure.
One or two probably.
So save it now.
It will go big, big, small, normal.
Good, because it will override this.
Number two, if we pass some value here.
Good.
Now you know how we can use the Hashmat, how we can set the clinic size and we can get it up.
Good.
Now you don't need to control this here.
So that was the final step.
So we went we went on the last one and that was pretty much easy.
So our job in the next election will be to create from number one on to number eight.
And for that reason, we need to create a function.
Karkoc patients in that function will loop through each and every patient and will grab the number,
because here we do have in the day we sending the patients.
Here is one of five one seventy two three three three three is sixty six or the number of patients in
each clinic daily.
Right.
So that is pretty much it.
I hope I'm going to see you in the next one and read the documentation again, because when I do this
it will be easier to understand.
So that's pretty much it.
And I will see you in the next one.