‫Instructor: Hi, within this lecture we are going to learn
‫about a concept called classes.
‫So far we have been working with classes anyway, right?
‫So we have all these methods inside of our main activity.
‫And if you look closely in your main activity,
‫main activity is actually a class itself as well.
‫So we have all these methods and we have all
‫this class surrounding all these methods as well.
‫So class is the bigger part, over here,
‫class is like a blueprint of programming.
‫So you get to choose your structure,
‫you get to choose your methods,
‫you get to choose your variables, properties, like options
‫that you're gonna get or you are gonna provide in your code.
‫For example, let us think that we're going to have
‫some musicians, okay?
‫We can create some musician names, for example,
‫like string musician one and string musician two, right?
‫And assume that we' re going to have the age
‫of those musicians as well, like age one and age two.
‫And suppose that you also have instrument of that musicians,
‫like string instrument one, string instrument two.
‫So suppose that you're gonna have like a hundred musicians
‫and it would be a little bit difficult for you
‫to do it like this.
‫Like musician one is James, age one is 50,
‫instrument one is guitar.
‫So after one point you will lose track
‫and it will get complicated for you, right?
‫So rather than doing this, you can create a class or model
‫of a musician and you can give it any property you want,
‫and you can have a more structural way of dealing with data.
‫So this is where class comes in.
‫Like you can create your own class,
‫you can create your own structure, your own blueprint,
‫and you can have your own way
‫of having properties, having methods.
‫Over here we have this main activity
‫and it's a class itself as well.
‫So this extends to something called a compact activity.
‫And we're gonna see what extending means later.
‫Oh, but this is actually a class and we are working inside
‫of a class anyway, so you should have a class.
‫And we have created class over here before, right?
‫We said new Java.
‫So that's what we're going to do, now.
‫I'm gonna create a musician's class
‫and be aware that I'm making this M upper case
‫because that's how we write class names.
‫So all we had to do
‫is just write public class musicians actually,
‫inside of a Java document.
‫So this is our class.
‫Now I get to choose
‫what kind of properties that I will have
‫inside of a musician object.
‫So for example, I can say string name,
‫and then I can say string instrument.
‫And if I want to add an age,
‫I can edit, it's age and that's it.
‫Now I get to create a musician object
‫out of a musician class.
‫It's the same thing like creating a string object
‫from a string class like this.
‫So let me come over here
‫maybe under on create or let me create my own new method,
‫so that it would be a separate method,
‫so you can keep track of things in a better way, okay.
‫You don't have to create methods right now.
‫All we have to say public void.
‫And over here, let me call this, make musicians.
‫So it would be explicit as much as possible, okay?
‫And under this make musicians method,
‫I'm going to create a musician object.
‫So if you come over here and take a look,
‫we already did something like that.
‫So it's the, it's basically the same thing
‫like saying string, my string, okay,
‫we are gonna say musicians like this.
‫And as you can see now it's appearing
‫in the results as well.
‫So musicians is our class
‫and we are going to create an object out of that class.
‫And we can name it anything we want.
‫Like James for example.
‫So James is a musician's object right now.
‫James is not a integer, is not a string, is not a bullion.
‫James is musicians and I can just say new musicians.
‫And I can actually give the property values afterwards
‫if I want to.
‫Like I can say James dot,
‫and I can reach all the properties that I have defined
‫inside of my musicians class.
‫Now what do I have over there?
‫I have the name, I have these instrument, I have the age.
‫Now if I say James dot, I can reach all of those
‫as you can see, age, instrument, name.
‫If I had another method or something,
‫some kind of property over there,
‫I could have reached those as well.
‫So I can just say James dot age is 50,
‫James dot instrument is guitar.
‫And I can just say James dot name is
‫of course James itself.
‫So this is how you deal with classes.
‫This is how you create models for your own objects.
‫Now I get to create whatever I want,
‫like an object inside of my,
‫under a development environment.
‫Of course, there are a lot of other things to consider
‫when you deal with classes
‫and we're gonna see a lot of those
‫in the next lecture as well.