In the last video we left off, having just created class user right here, once again, if you see
a warning around this class definition, that's totally fine.
We're going to fix it up in just a second.
So in this video, I want to focus on our implementation of a user.
Remember, we had said that a user should have a couple of different properties assigned to it that
will be randomly generated.
So that should probably be like a user's name and their location as well.
To get started, I think that we should define a couple of different fields on our user class and then
we can figure out how to randomly generate those properties.
All right, I'm going to flip back over to my class definition and inside of here, I'm going to assign
two different properties to my user.
I'm going to say that every user is going to have a name property that is a string and a location property
that's going to be an object that has a latitude that is a number and a longitude.
That is a number as well.
So that stands for latitude.
Eleni's stands for Longitude.
Remember, we can use latitudes and longitudes to model a physical location in the world.
So we're going to eventually randomly generate a latitude and longitude, assign it to this user and
use that data to decide where to map a user on our Google map interface.
OK, so now that we've defined these properties right here, we need to eventually initialize them.
Remember, every time we define a property, we need to either initialize it on the same exact line
or inside the constructor.
Usually we will initialize the property on the same line if it's going to be some hard coded value,
but in this case, we want to randomly generate a name and a latitude and longitude.
So we will instead do our initialization inside of a constructor function instead.
So I'm going to define my constructor function right here like so.
All right.
So we've got our place to initialize the name latitude, longitude.
All we need now is our randomly generated data.
So for that, let's take a look at some documentation for library that we're going to use to generate
that information.
All right, so quick link right here, we're going to go to AMPM, Bascome and take a look at the documentation
for a package called Fakher.
The FAKHER package gives us the ability to randomly generate a bunch of different types of information,
which makes it really well suited for the project we are working on right now.
So I'm going to go to James Dotcom.
Once a year, I'm going to search for Fakher at the top and I should see it as one of the first results
on here.
All right, so here's the documentation, you can scroll down a little bit.
And underneath AP right here are not AP next section down here we go apply methods.
This is the absolute extent of all the documentation we get.
Unfortunately, it's not super detailed.
So what this is essentially saying is that the FAKHER package has a module inside of it called address,
and we can use the address module to randomly generate a zip code, a city street name, a county,
a country state, latitude, longitude.
Well, those look really relevant and so on.
Likewise, there is a company module that we can use to randomly generate a catchphrase or a company
name and so on.
If you scroll down a little bit more.
You'll also find a section inside of here called.
Name and we can use this module to generate a first name, last name and so on.
So as you might guess, we're going to use this name module to generate some information for our user
will use the company module back up here.
To generate some random information for the companies we create inside of our app.
And finally, for both the user and the company will use the address module to generate a random latitude
and longitude.
OK, so it looks like the FAKHER module is really going to take care of all of our data requirements
for our application, so all we have to do is install this thing.
So to install this package, I'm going to flip back over to my terminal inside of my project directory.
I'm going to stop the running pozole server with control, see, and then I'll do an NPM install.
Baker like so, and that's pretty much it.
Now, the package is pretty small, so it should complete installation rather quickly, once it's all
done, will start up parcel once again with parcel index HTML.
All right, so now we can flip back over to our editor and make use of Faker to do so, I'm going to
go to the top of the file inside my user file.
And I'm going to import the FAKHER module import statements inside of TypeScript Look identical to import
statements in 2015.
So if you've ever worked on a react or angular application, you're probably going to be right at home.
In other words, to access a module that we installed with NPM, oh, we have to do is write out import
Fakher from Fakher like so.
So that's going to reach into our package.
I mean, Noad Module's directory right here.
It's going to find that FAKHER module that we just installed and it's going to give us access to all
the code inside there through a variable called Fakher.
Now, there's just one little issue here, if we hover over Facher, we're going to see a little air
message right here.
It says, could not find a declaration file for Model Facher.
Now, this is an air or a warning that you're going to see many, many, many times as you start to
work on typescript projects.
So let's take a quick pause right here and talk about why we are seeing this little warning message.