Object-Oriented Programming in C# | Ahmad Mohey | Skillshare

Object-Oriented Programming in C#

Ahmad Mohey, Software Developer & Instructor

Play Speed
  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x
35 Lessons (2h 46m)
    • 1. Introduction to The Chapter

      0:51
    • 2. Object oriented programming

      7:55
    • 3. Methods Part 1 (The Basics)

      7:52
    • 4. Methods Part 2 (Parameters and Return Type)

      7:55
    • 5. Methods Part 3 (Value vs Reference)

      6:19
    • 6. Methods Part 4 (Overloaded Methods)

      4:17
    • 7. Simple Method Exercise

      3:28
    • 8. Overloaded Methods Exercise

      6:13
    • 9. Classes

      8:52
    • 10. Constructors

      2:31
    • 11. DateTime Exploration

      2:56
    • 12. Static Methods

      4:17
    • 13. Scope

      5:45
    • 14. Inheritance

      4:39
    • 15. Encapsulation

      7:39
    • 16. Abstraction

      4:06
    • 17. Polymorphism

      7:10
    • 18. Region Keyword

      1:50
    • 19. Sealed Classes

      2:13
    • 20. Nested Classes

      3:15
    • 21. Static Classes

      4:23
    • 22. Partial Classes

      4:23
    • 23. Namespaces

      7:23
    • 24. Structs

      5:01
    • 25. Classes VS Structs

      1:48
    • 26. Enumerations

      5:46
    • 27. This Keyword

      4:57
    • 28. Interfaces

      11:37
    • 29. Interfaces VS Abstract Classes

      2:01
    • 30. Exception Handling

      4:32
    • 31. Exception Exercise

      6:32
    • 32. Composition

      2:06
    • 33. Aggregation

      1:41
    • 34. Association

      2:24
    • 35. Summary

      1:06

About This Class

Hello and welcome to The Object-Oriented Programming in C# Class, The one and only course you will need to learn object-oriented programming in C#. In this class we are going to cover all of the topics related to the object-oriented programming in general and how to apply it in C#. 

Some of the topics we are going to cover in this class : 

  • Understand four pillars of Object-Oriented Programming (OOP)

    1. Inheritance
    2. Encapsulation
    3. Polymorphism
    4. Abstraction
  • Learn how to develop and work with classes and discover different types of classes such as static classes, nested classes, partial classes, sealed classes and more.

  • Learn how to work perfectly with methods (Parameters and return types, static methods, value vs reference, overloaded methods and more)
  • Understand constructors and how to work with them

  • Scope of variables

  • Work with namespaces

  • Understand structs and the difference between structs and classes and when to use what

  • Enumerations and Interfaces

  • Exception handling

and more topics are going to be explained in details.

So what are you waiting for....let's start!

Transcripts

1. Introduction to The Chapter: Hello and will County the object oriented programming one and the ship that we will start learning about opera training program. We will first start with the concepts, the concepts, the basic concepts of the object oriented programming. Then we will start dive deep and talk about the message. And what are the need for using a message? And how can we do the magician? We will also be discussing about the classes. But its need for the class is how we can do them and see sharp. And we will be discussing about the four pillars off operations programming the inheritance , how to in her classes and encapsulation portable pheasant abstraction. I know this technologies looks complicated, but trust me, it's not. We will start explaining them one by one, and we will see in exercises how we can start doing this T shirt. So go ahead and start injected to you 2. Object oriented programming: Welcome back. From now on, we will be hearing a lot about the object oriented programming and in general, in the software world, you will be hearing a lot about the object oriented programming. So what is object and just listen. We will be clarifying the concepts off object oriented programming that through the next chapters we will be done. Dive deep inside the object oriented programming and see Riel World examples off the object programming. So let's go ahead and trying to clarify it in the concert will be a trench. Programming simply is a software design. Programmers or developers defines a day tonight before the structure and also the functions already message that can be applied to this structure. So in this way, he didn't structures, becomes an object. That's why it's called object oriented programming. It's all around the object object here that specific, didn't structure object, have specific functions. That's why it's called object oriented programming. Let me clarify for you some of the year the victim lodges you will be using involved in France programming and the very famous wanted the class and you have seen me using a class when we used the date time. Remember the date Time, Time at a time. Actually, it's a drive, of course, but it's a class. Class is a custom data type. So the time was a class, and we have used and in many instance of this, and you yourself used it many times class state time when we get some assignment. So Class defines all the colored properties for a different objects That belongs to, for example, a core a core Kambia class. And under this class before, for example, there can be many card friends or manufacturers like Mercedes or the Ford. This can beat examples of the class. Objects, on the other hand, are a specific instance off the glass, for example, a cores BMW X four. This is a specific class story of specific instance off the class. So this is an object missile actually, is a combination off instructions group together to achieve some results. So there he set or a plug of cold that together perform a specific task related or even lung related to the class would be, yes, the object that it is defiled with, Well, let's sing it. The property probably actually provide a selectable mechanism to read, write or compute the value of private field. Sometimes it's called class variables, and we will be discussing about properties, message objects and the classes. Dignity. Hell, we'll worry about this. Let us check this example in here. If you have a vehicle, Vic, you can't have two divided into two. A wheeled vehicle were in on real drink and evil. The wind vehicles can be divided into four wheel vehicles like this here, core or toe wheeled vehicle like the bicycle wars motor possible and then only of the sea and year in this case. And we can see the Putin, of course, is a C vehicle. And the plane, of course, is an area we can have properties for this thesaurus properties. The color is manufacturer max SP, carriage capacity, electricity and gasoline. This is all in on attributes or properties. Each vehicle has an vehicle is different from whatever Start stop Dr Refueled and all this verbs here on the actions that these vehicles can take. The can start, you can cry, they can transport people. So this here is the actions. BMW X four is a specific model or this Trevians or the 40.787 A famous airplane or the camera? Jackie K. X for tired old five. Actually, I don't know. There's I just Googled it. This is a famous motorcycle for the Kaiser Love for cycle, so this can be a specific model off vehicles or this different types of vehicles. So what this has to do with the object oriented programming All these things that we have been discussing about? Guess what? Bacon can be a class. This is the upper class can be called the based glass or the super super class, or it has many names about the famous name is a paste last, and from it can be drive these up last cold wheeled. And from this wheeled vehicles can be another step class scored four wheel vehicle and this four wheeled vehicle have some properties. So here is the problem that we've been talking about this or properties and can have some message for functions that stops storage or, as we have seen or any any different action. It can take this vehicle, and this year, the for every end of, for example, for any of these or other times, these are the object itself. This for the Thea object. That's all around it. So the BMW X four can have some properties. A color in Mexico appeared where the power that's working with is and can have some messages and can have some subclass and parent class who this year I hope that it demonstrates, is a concept of how difference programming works and the the class properties message and object because he will be stuck in with this and the seizure programming. Actually, so one last thing before you go, we have to the trying or mentioned the objection. Programming has a four basic pillars. When we're talking about that, we have to Benson then. So, as you can see here, distemper Lee s. So they are the inheritance in caps, elation, putting more says and hand obstruction. And don't get scary. This technology I know maybe it's a little bit is curious looking, but they're left. We will break it down one pie well, but let's just explain it in simple words and the concept of each one of them to inheritance that the process of creating new class by extending existing class. So remember when you had the parents last call vehicle and we drive the corrupt class from it cold air vehicles or the four wheeled vehicles. So that's in her terms. There's apparent class or paste last, and from it there is a surplus, and we will be using this. I love and actually singer when it's built, it's using this technique alone. Encapsulation in confliction simply is a process of binding detained members, variables and properties and will see this and was its together and have the work. And which one is Xing, which one polymorphism fully actually means many and morph moons forms. So fully my friends together mean that object or the function can take different forms on a specific conditions or a specific time off the program, and we will also be discussing this. Don't worry. Obstruction simply means it's process of showing only the essential features, often object to the outside world and hired the relevant information. That's politically so. I hope this give you a nice introduction to the object trains programming. Next, we will be doing all of this. Don't worry, we'll do gonna understand that. Well, this was fun. See you in the next lecture. 3. Methods Part 1 (The Basics): this lecture we were discussing about missiles, Miss. It's actually a very powerful tool. Can see sure. And they are commonly used in C Sharp. And actually, missiles are very powerful and used in many programming. Laugh. It's these days we will be seeing this lecture, how we can convene every pay sickness, it and seizure. But before we go ahead and do this, let me explain some concepts. Isn't it just a cold look that contains a serious statements program? You? This looks quote to do a specific desk. The missing actually apply a concept in the software for lead called Dry right? Actually, I don't like the English word great, but it's ah, it stands for don't repeat yourself, which means that if I have instead of Flynt's or a specific things that they would be doing many times in my program, I don't have to type it every time. I just go ahead and place it inside message and each time of life when this set of codes, I go ahead and call the message and we will see how to do this. Well, let's sing before you go. Every message has something called Mrs Signature, which distinguished each message from another. And this signature is the name of the message and the parameters time, the type that the parameters are defined in this message, not the prefers name. And we will see this as well. Now, enough with presentations. That's go ahead and try to do a specific and a function. And actually, before you go ahead on time, anything. All the programs that we have been developing a spoiled programs, all of them are a time inside this creases or packets in here inside the main. This main actually is a function or missing. This is the main message in our program files. So let's go ahead and find some variables that define a bee suit nd and go ahead. L said the A two for us. They do 23 Cissy Kohler and go ahead and I would like to define another injured. I call it had results. He's old. Zero set it to zero in our lake. The end result to have the forest industry or actually the A and B and and it through the result would like to go ahead and also display this in a message. My plane and I will use the string interpolation. Actually, this time remember the string inflation. We have to type d dolar sign and start typing. So I only tell it that year variable a plus. Very well. We need equal during temple now if you run this. It was very simple message in here. Five plus tree equals eight. I'd like also to answer extra lane here. Like a bullet you'd line. You know what this is? I just want to This is the that long process. Now let's go take all of this. Copy, Pasted name. Change it that this c and this is A and the d 02 to 10 and the address goal to be the see here in the deep in here. I see. No, let's run it again. Well, you can see first time it was five streets, eight persons done. The message 15 plus 10 is Dr and Chris is not again. I don't like to see this repeated in here. What was done? Post is going. What if we have process or him processes so we can go ahead and place this here inside the several trunks? Now let's go ahead and get out of our comfort zone in here. This is the main comfort zone that's go ahead and get out of it. Now let's dive. To greet the function, we have to follow someone. We can go ahead and type aesthetic. And don't worry about this stuff. The key word we will be explaining about it in is a bit of a lecture void. What it actually means. That this function does not return in value to the main function orders a colder function. And we will also see how can return types and the next lectures to the cooling function. And let's go ahead. And this play message this is the name of the function and the name or the correction in here shall be followed by appearances on, uh, pear off creases or briquettes. Now we have ive function that we wanted to call this. It will be the witnessing. Now let's go ahead and take this line here. Constant tried line and place it inside. This from now, if we want to program, nothing will have it just the ed operation because I did not call the function and we have the function it's declared, and it's doing something that is which is is playing this message. But I didn't tell it to comment and cold now to call them. Just go ahead and I display message. As you can see here, the entity sense individual Did you now see is that we have some and sort of a new message , and you, uh, function Ramesses called display message. Now let's go ahead and choose it. It says that we called muscle, just type it. And for with currencies, let's go ahead and run this and well, that now working forces them. You see, it's twice in here. Also, we have only that. Would it want I What if I wanted to end more messages like income here again until this business is run by Rene? Now let's go ahead and run it busy. Now it's playing the two messages I can even from here the day that General, they just go ahead. I'm type any date, or you can use the time Mrs. They can come here until they turned up. Now I like to show on Lee the time. It's still it that it's only the time. It's one we're finished on. Sorry. Okay, we can run again As you can see, the process is the This process is run by How about, for example, Spanish on? And here's the time. So this is how we can create a three basic message. And teacher, I hope this sleazy ends here in the next picture. 4. Methods Part 2 (Parameters and Return Type): we'll come back now. Continue our discussion about the missiles we will discuss in this lecture. But editors and or 10 times here is your Spoelstra lab that we have developed in the last picture which displays this three different messages when it performs an ad operation. What if I wanted to, uh, actually do be evaporation in a separate function? Somebody come in here and compete and you function called static voids before my ankle it perform and operation. You can go ahead and name what everyone but make it meaningful. New What note here that all of this variables inside the main visible in here the only visible in this Mr So if I wanted to you the end result using visual studio inside of this message here is not allowing Doesn't even see it for the game he see would even d You're not visible. So how can we sold this issue? We can For now we can go ahead and sign our interest Ult. Now we have a variable that will hold the addition The value of the addition operation now , one important thing that we can do that we can pass the perimeter from this functioning here to dysfunction here and in this function, I will come here in the regulation and you will be receiving an endurable called a and and very well called B. And remember for the signature of the message that the data time is important. The name is not. I can call it X, he or whatever. It will go up now the some way I will best the MP or the two numbers or the sea and the whatever number they want in the exam. And I will do the operation. Actually, let's go in here and take this operation. Go ahead, Lee said, called Love the CND, the X cam boy, which is defined in here. Well, now let's go ahead and tell it that ex and line. And now we have a function now that takes two injures and and they've and display a message for this. We can come in here now. Let's go ahead and remove the message. Move the evaporation from here and again remove the integration. The message. Now we only lift in the main function with I think liberation and the assignment of these variables, and we can just go ahead until it to perform an operation. You see, now we have to function. Did you season this blame message, reform and operations? That's why I had entered it, that the 1st 1 would be a Camby. Now the A will be a silent X and B will be assigned to weigh and people here and it's a go ahead until it again, before and oppression seeing and the well again the city will be assigned to X, and you will be assigned why they turned this and see what the output will be. Never see. It's working like before we have the function. You're doing the job for us with one line. No, they know where repetition. We have maintained the dry concept here, but actually there is no one message display this re message displayed so I can just come here. You see inside this function until it that called the function that's called spleen message you seen and it's from this and, well, works like magic. Then we have made the function to do the operation and the function were a message to display the messages for us. This is very powerful. Agent to one less thing. What if I wanted. Now I have this Mr Yu domain passing some values are variables to dismiss it. What if I wanted to be performing that operation to get something back to the me to return something to return as a result. For example, I can do this very easily. So I will come in here until it the Let's stop this. Actually, it's command this while. Come on this for a while in here. Go ahead and change this void. Void means that this function doesn't return anything and you can see doesn't return anything. It declared the variable makes of operation display the line and pulled another function. There is no returning this. Uh, we'll avoid me. So if I would like to return something in our case here, it will be an inter. It would be in addition, I come in here and change his voice, too. Now, this is an implicit easy, but it's giving me an error and you can see here not only code passes return a value because it needs to return something so I can come in here and there's a new key word called Return. I can return the end results is it going to be here now? This is and you function and it's an end missing, actually. Functions and message All the same, they looked, uh, don't get confused. And now it do some operations and return. Is it? So I will change it a little, so I will not displayed eating here. I will displayed. So this message, actually dysfunction actually doesn't display. Just do the ad operation. And in here, the message of the displaced. But the result, actually, I will assign the n word with the return from this function into being and result. So whatever is returned from here will be assigned to the ad resulted. Can't get it. And let's go back and be a B again. Okay. Yeah, Let's again this you hear? That would be when they have for weeks for the year see, Andy Children to do and again. Now let's go ahead and run this see, working again with a different techniques. But the message is no displayed. Go ahead and we can again this Blake in here again. Let's go ahead and on this and it's working as before, so I hope this was easy. This is how we can best arguments or predators to a specific function. And this is how we can return something to the cooling miss within here. Which is mean in your case, the way it is easy and fun to the next lectures. 5. Methods Part 3 (Value vs Reference): we'll come back in. Just lecture. We will be discussing about one of the most important concepts. Things he sure programming, which is mostly variable reference or by value. We have seen how can we pass? You have variable value to the the message that we've just committed There is two times off passing variables to be missing. 1st 1 is cold, passing by value. This means that you're using a copy. You are not using the very boats off. The value in this variable will never change that. We will see before one example. But person get point difference means that you're using the variable itself. So whatever you're doing, which would change desirable, it will affect it in his ear. Cooling this and we will be talking also about the risky word and let's go ahead and seizes . Let's go ahead and open this product message. Board Street. I have something cold in here for you, and let's revise it simply and just a string variable, bold first empty and second plea and I signed some random names to this first and second amply and just a possible straight line to display this using string interpolation. This is just displayed as it is, just as the formatting and them just he was playing the first name in second name and taking some you like using Z Vex, elation, Escape secrets. And then I have the missile cold change names in passing the first name and the 2nd 1st simply in the second and plead with the your function here and the function inside if it it changes the first and second. So it was David Ismay stuff here. What some and they are believe you, Erin and tells. Think Alvertis other is performing. You can use it in the movies, and again we're back to the main function and this bling again, the first and a second complete to seize values. Let's go ahead and run this anti additions, as you can see here in the So I remain. We have David dismissed with here what some You know, we went outside of the main dysfunction here, change names, so we have different names. Levi Aron of Faro Sons are. And when we were back again to the main value changes. As you can see you, it's David is most and Sofia what's also We have a signed different names in Wana function . So this concept here that the fold off the seizure is called opposing by Ville, which moons in You're using a copy off the That's saying I live in a copy off the variable , not the variable itself. So again, that's from this before we go ahead and change it in main function. It's David Smith's spirit. Some outside, it's believed he and L zero inside. It's David Ensor Fee took the values of the variables. Never changed school, passing my value, working in a copy. Now how can I work on the variable itself? Were using the other way messing by reference completely. Just come here and there with and in here and elegance seeds give me ever hear because it needs to be also defined. Now see sharp or the complainer know that this is passed by reference. So whatever heaven in this mentioned a year will affect the variables. Now that's really wound. It is inside the main message. It's David Smiths and Sophia. What? Some outside It's Bolivia. Aaron Alarm Salazar and again, inside the main message, Deve Abel's have been a change. Now there is no more David of Sofia it's Bolivia and LZR. So she's difference between besting waitresses because it we change it outside of domain. It's stuck with it. Changes river reference keyword. Know this and reference key word needs to be initialized before I'm sending it. For example, if I come here and comment on this line commended this line and this one in here Now, what will give me an error? Because it needs to be said to some value also that they have here. I declared it here that I have a string first name and second name, but still giving me an error. It needs to be initialized before it can be used. So I come here. See, there was gun here. It was gone. What if I didn't want only shorelines and I didn't want to give it a value which worry used ? I can just go in here and you've skateboard, and we have seen it before. I would keyword Thank you. Work do the same job, but it doesn't need to be initialize. Yeah, well, you're doing the same work. This is busted. It's remove this now it's bustling by reference as well, but working it's working without the centralization run this now. Working normally. Actually, I commended here the line saying, David, dismissals fear once because that's why they're not desperate displaying in the message. Okay, One last thing before you go and with the parcel off the archeo, their recommended the declaration of the first name. And second, I can come here and out stream weren't again half string and I d sliding the very well inside of here. Three. Powerful keeper. Let's go ahead two. Run this and it's like we're expecting. So this is the difference between the passing by value and person preference and help to use you. Key word. And you just was seething. It's humans in the pictures. 6. Methods Part 4 (Overloaded Methods): Now it's time to discuss about overloaded visits. Overloaded message means that you can have the same missive name many times he has. You did hear me, right? You can have the same missive name many times, but with a different argument. We just kept this concept the earlier we were talking about the signature. Some essence. If you recall this and then picture. Okay. Now enough was the presentation. Let's go ahead and try to do this Here we have a small program that defines it. Yes. String old guest name and display a message year. Hello to your guest. What is your name? Imagining that we are You know something? The input taken and signed to the guest name Variable in here and it's empty. We will call the message. Cool. Welcome, guest. As you can see, it's here. Just saying Okay, we love you. Enjoy staying at all and without any specific names. So what if the user give us his name or her name? I would like also display message but having its name. So let's run this. Actually, it doesn't did not sign anything for some reason, maybe his secret agent or something waken just ahead. He did not give me a name. Receptionist was a Okay, Have you, for example, doesn't see symbolism. But if we run this and you're give us his name, for example, we'll have no I would like message to be displayed to the user with. So let's go ahead and try to do this here. The s Let's go ahead and else, which means that users will actually be giving cost because the gets name here will be empty. But this here will call the same message. No, I don't like to do this. I would like to go ahead and use the portal concept off the overloaded message, and I will cumulate the same Mrs name. It's welcome again. But as you can see, it's giving me an error because you have the same. Here's program. The classes moving in. Already defined. Remember cold Welcome. Guest was this same parameter. Here's a secret. This same perimeter, it does not in a parameter and this one doesn't take any frankly, don't make it different from each other to make it another one. We can come in here that this would be taking a string name Never seen here is gone and the compiler and t shirt there along with this. Okay, let's go ahead and try to. It's a messaging. Here. Go use a string interpolation in here. Little sign changed the most since Q. And here, I'll give it meaning? No, I specified his or her name with a message. And in here I will tell you that in case of elves and we have a guest name, go ahead and best the name. Let's go ahead. And the neighborhood school kissed me, I guess. Let's go ahead and run this. Okay? Not your name. Just like before. Yeah. Let's go ahead and give it a name, for example. Give it some. Thank you, sir. We hope you enjoy staying out. So this is how you can do the over loaded Mrs N. C. Sharp. And of course, you can do a certain while or force one depending on you know, you and well, let's think before you when we were choosing from here guest Mrs, I Go ahead, type Coleman here. See, it's telling me the entities on. So you're telling me that there is two virgins of this Mr Lear? Welcome Guest First form thinks no arguments, parameters and the 2nd 1 take your change. Which is Do you get in here? So very powerful. Were interesting teams of mixed picture. 7. Simple Method Exercise: actually, right now, I have a small exercise for here. I would like you to go ahead and ask his usual about his name and just play a welcome missed. And I'd like you to do this using the message techniques that we have learned. And you can go ahead, create one or two message to do so and just in the mean Mrs Just the leaving. Empathy only recall. Do you think messages would be doing this? Great. Give you some time to do it. Okay, Let's do it together. Now. As I told you, I would like to leave the I mean here. Just the cold. Every only called the message. So I'll go ahead and get the first Mr Static avoid and get name. So dismissal here will be the one that getting the name is used to string Name. Actually, in previous lectures we've been defining sitting the strings to this year. Let's use some more sense that you can come here and with strangers and go ahead a name. Equal users will be entry because under mainland earned to go ahead and read another one study lawyers will it will not return anything. Cool. It saying, Actually, this one would be displaying the message so it will be hitting the name Well, that you will take years. Variable table starts, drink and in here are actually display. Counseled. A bright line used the string interpolation. Go ahead. Will come. Thank where is he? Everyone and single. Now let's go ahead. And actually who this Mr say hi from the missile which is getting actually commits the name , of course, because it's giving me an error because it means telling me that it needs an argument and what will give dinning? Okay. And then you're just in the main. I will only choose to cold get me. Okay, that's from this. My name and as you see, will come back. No, let's revert this week. So we called the gate name function from the main. So the compiler will go directly to this mess in the year. And this missile redefined cold name and was taken. It was from user and we again cold. Another missive cold saying hi. And it's taking the name is an argument. The l d Say hi, miss and only displays this message and well, this is me. So I hope you see the powerful, the portal list of the year, miss it and how it can be organized and you go. So I hope this easy seeming the next lectures. 8. Overloaded Methods Exercise: we'll come back now. It's time for small exercise about the overloaded vessels. I would like you to go ahead and find street and variables holding whatever you want and double variables. Also three of them. And I would like you to make a function to air and be his friend. I am being see also in case of planetary numbers and double X and worry auditable exploit NZ. Okay, go ahead and try Good in your Okay. Well, this was easy. Let's try to do it together first. I will define these re verbals A i m p c and also I redefining g result. That would be chisel, but I feel safe was the result. Go ahead and funds double its Why he level result. Let's go ahead in the sun. There in the interest bolt, Sit here A to let's keep it so Be sited to To CEO said it to three on the double's head inside the x two, for example on the why else did it too. Z said it too, just okay? Yeah, its decline since he results contains resulting Yes. You okay? You know, we have the different variables at different times in chalets to go ahead and try the function that will displays. Let's go ahead and making use, and the first games that will be doing is the end. So I'll tell her isn't the return flight of the message and call it a swarm it would be taking and the 1st 2 months and a And actually, this is not the same year changer. That's confusing. So one okay, that would give me an inter vehicles. It's expecting me for insurance eventually will return and anti someone reasonable frequent . Now it will take yeah to injuries. And after. Let's try this one. So we define over Rebel. That's go ahead, console the front line. I will inside the right line, the functioning frenzies and and the main enemy. Is it just the cause of the trail client a normal that we've been using and inside of it? And did you before missile here, which will return number which will implicitly go over to a string and being displayed inside very right now and be to treat it's street very good. What if I wanted to end there? See variable? It will not work because it's telling me that this is overload. So we're missing the form attic street arguments. She if I wanted to come again here and make another one freezing perimeters and make it a mystery and I will do it. Three. The error is gone. Run under. It shall be six. Yes, because one to Ansari is six is my king and try to time the x Why and the now it's giving them a different era. Well, the function that takes Sweden injures those three numbers are injured. No devil. Now we need to go ahead and double well, this one to go ahead and called this the same name of foreseeable the same name. It's time double and it would be taking double, double and double can go ahead also and do the versions. It takes only two with industry then this is a versions it takes only if we were to run this we will have. It's for this is easy and operation off the three numbers in here. So we've created missing vehicle before ad in four different ways. Phase two time that was singers second was doubled in one time and was two variables or to predators only the second these three parameters and the same for the level. So this is how we can compete the overloaded message. And again, if we were to come here and check it now to compiler 40 doings that until exams is telling us that there is four different virgins off this function as you can see them here Okay, it was easy. Here's the next lecture. 9. Classes: Now it's starting to discuss about classes. This is actually very important concept in object programming, and we have seen for his lesson in this chapter. Glasses simply is include print over template, which contains a missile, variables and properties. A particular kind. Let's go ahead and you have been with a line isn't so sure. Previously way have seen that we can go out of this mess of the year, the main message and start coding. Or do I kissed him? Methods to do custom actions. Worse. Now we can even go outside off this Praises were practicing here, which is the class program so bold with programs that have been developing were inside the flask old program that was created when we first created this project. So let's go ahead and try to create your own custom class, agreed Glass. So we we time the word class and its name Golden Prison. Okay, and this is coming and closing. Now we have a glass. It's heavy. Doesn't have insane inside of it, but we have a glass. We can go ahead and start adding some variables. We can go ahead and it has a string. For example, First name and it has weather stronghold. Last plane. You can have a date Time. I called it. For example. First day it can have some kind of country or address. And there we have some valuables. I can come here now and the person that, as you can see this seen here daily Sun sees that we have a new class cold person. How cool it the exam boat person one and u. N We will discuss about the new person currencies in the upcoming lectures. Then we have the class A person or an systems called. They're one we can use now. He risible when you can see it's of type person. But actually I come up, axis any off. Just variables in here because you're hidden from me to make them visible and other class, I can make it public. No one wants to type like I've only public in the first name. No, I can. What is it? Yes, I want to do for the date. I can come in your public. You know, I have access to the first name adversity, but actually, this is another biscuit practice. This is exposing all variables to the outside classes with the outside world. So there is a better way to do this through properties. What's actually can him bus Didn't mind whether this variable needs to be set will get using the full of wrinkles so I can come here and death. I will create you thing, for example, for his name and capitals. Here there is a body of the property and I can come. You too. Time to get word. This is how to get the value off a profitable property or a variable in science, off property Get again creases And that I like to return the first night variable First name. I can set it also, These people, the guy that they would be using our class can also get the money I can. Sitting first name said it through so called values. That would be so. This is how you create a property. Now, if we come here, we will not be able to access it again. Because thank you work only by the fourth year in a public there having a private before so no overrating the default of things and the link it's it's public. And now you can see I can't excess he first name. And can you see the difference between the icon here? Now let's make this public. This is the first name here is lower F years with left to let's do this comparison quickly . Here is the variable itself limited public notes visible And here is the property itself venue Caesar's He is different icons between the variables and properties. Now let's go. And above this met breakfast from here. Now we can go ahead and even an war properties does this You have probably streaming last name again. Your village get and sure variable Last name Last name was small held Liu said TV once name to some kind of value that we will best to it. So now if we come here, we can access was a property. As you can see, the last name and the first let's do or the last two variables handless dual purpose tourism. And actually I'll do it. Yes, here, which is what we have seen before we were doing before Luke. Now there is a slip it for the properties. You just go ahead on time, the our whole being and two times on the dam on their bottle on your keyboard. Now the property is done for us. We just need to remind the time and go ahead and it's date time and it's name would be first. Okay? And it's another way to do the get and secular going through all of this. Now let's go ahead and find another one from two taps on a keyboard and it's drink and name it, don't you? Now we have four properties with this. As you can see it, here is the first date country and first name listening. I can come here now and assigning values to all of this first name, for example can be but come again to be most name it is you and I go again time the country , for example like you. So this is how we can assign and creating. You can also come here and signing of one a person I can go with a pair to now we have two instance of this class person and I can also come in the US There's some to wonder signing beautiful, different Jerusalem and I found that a first name is Tim again. I come in here and that last name, Actually, let's make it. Leave it out. Sneakers. Let's go ahead. And if one country can be, for example, really a present? No, here is e to persons was different. Data can go ahead and actually council the train plying this. They can go ahead cause into quite line. No wonder first name can't wait. And also the person to personal. So it will be much. And him here. As you can see. There we have the slide. What on the structure using the amazing in Purcell. Last keyword. Okay, well, just easy to you in the next lectures. 10. Constructors: Now it's time to talk about constructors. Instructors of Just Message's and Mrs with the same name as a class name on the Earth flared the movement that I am creating an instance off the cliff itself. Let's go ahead and see this you see here this new person currencies. This is become stricter and Chris Sector usually used to a convenient and initialize er's when its allies he variables and the class remember when we used the date time class and and here is deconstructive for the date time. This constructor, we have some values in the date. If you remember, it was that he sold value. We did not assign it, but the constructor me sorry to let's go ahead and trying to to meet the personal street, for example, a person gruesome three year were some. I go ahead and may I mean person three. First person, three personally as we're expecting, it will be empty. He was a mother, your stem and the circle on a MTB goes. I did not give it in value. I can go ahead and use the options off the constructors and give it that if all very footing we can go ahead and public to be able to use it. And I will name a threesome because the class serious cold person So the mistletoe take instructor share Be cold. But I can go in here and the full very what the first moon would be unknown Devil Any value that your Now let's from this you see now it's unknown because it does not have any values with constructor A sign of ready to wear, which is the unknown. And this morning come here and sign ready to it. You know, the unknown word would be the first name college, then you in the trendiest. So this is and we can use sectors of very personal and very helpful. Here's the next lectures. 11. DateTime Exploration: Now I want to do something like, Let's see, how can we look up something in C sharp itself for examples of the time class or the time struck? It's actually or is the class mass or in function, seizure? Let's see how going to do this. Russi chirp itself. Let's go ahead and meet you. Just leave it like this. Go ahead and name it if you'd like. Let's go ahead and find you late toilet Lee. I learned that this is equal structure, which is initializing systems. That way we want to display the date. Now it has some Are you? So I didn't give it any very better pass on. This is the work of the constructor. What if I wanted to give you the details of this? They defied actually this big time something called strict struck the similar to a class. There's some little differences, but we will go to system. Don't worry. Now we can go ahead, Chris s 12 or from here and go to definition and here it will take you to to see you. As you can see, here is the different properties and functions off the type. And here is the the time property now that we've been using to get the time standing in the time objective set to the date and time this is there is another way to explore a glasses, functions, instruct and interesting chirp which is you can go and view here and there is something called public Explorer. Well, an object closer. So in over your browser you can go ahead and like whatever you want, I can go ahead and am time. Date time on you see, here is the different. Here's the ad they mess up that we have been using for an years. Older description of it. You can see old the well said Properties that this struck this time has the description and like, we'll go ahead and even search for the mess class. Here is the man was all the missives that we have seen before and he was a description on every detail you would need. And even I can go search for some message like around Messing Here is a mess on here is over. Loaded missiles run can be decimal can be this one and this one See And here is a description. Go ahead and play was this and this was something like inside. This chapter ends you in the next lecture 12. Static Methods: Now it's time to discuss this study question. What did this, Derek, you were that is in front of every message. We have convenience before. Let's go ahead and dreaded beating you. Message call. It's a high study. I would say hi. Displaying messages is right of you close old trace line and right from the study. Strange way to read some of it. Okay, Now, let's go ahead, and I can see it here. Very, very straightforward. Most ingenious in here. Here is the message. Okay, so what if I came here and moved to study? Well, give me an error in here. This is total equal Rick, and build for the message. But actually, it's giving me an inter here because it cannot see that say hi anymore to type this again. There's no more saying hi. It's invisible. It's not readable wide. This Mr mean here. So why is this happening? This is happening because the missile aesthetic miss it. Actually, I can use a direct be result the need to understand. She ate and new instance of this class. So again, in order for us to use the message of the daytime if you remember the time here. I have to create an instance. Didn't you can start using all of this mrs here. But this is not happening to study. If I wanted to use the message without on innocents, I did not create an instance off the glass program Here is a class I did not create this. They just terrifically start using this. So this is what the aesthetic and messing me that they can start a rectory. Use it. Let's see, How can we do? This was the aesthetic. I can come here, for example, and look to go ahead and do It was a glass. I can go ahead by the way and create a new class from here when coming here until it you glass. And it's working the same for clarity and just using it in the same flight here. Okay, Class called prison. As before, it was a little B, and I will just make one mr them inside of this class. Cool it and saying hi. The same as the study quote I own Consul. The right line this boy from the none aesthetic. Listen, let's forget to make this public so it can be used in of glasses and we will discuss this in the leader. I can now come here and still not finding this. Say hi. I'm only seen this aesthetic. Say hi in order to use this, say hi. Inside the person class is to create an instance of the prison class. So I go ahead and be the person because it just any full, Uh and I have access to the seeing how you listen. This is different. This is the same high off the prison class leather say I aesthetics a high off the program class. Now let's run this agency pie from the united stated missing to you see the difference. So a lot of strict lizards. I need to create an instance off the class use and the requested. I don't need green An instance where you just go ahead and start using them. And he really the one of them had to use them. It was easy and fun. Unions and ex lectures 13. Scope: we'll come back now it's starting to discuss the vote. Discover favors. Let's go ahead and community you glass. Choose any item and go to the last year. We'll call it dogs. Go ahead and meet some variables with this class. A recall it string, for example. Lug read and don't name the color. It's often like political with buzzards training a dog, another one like it. See the door if you're in the game or and related just generi rainbow feeds like am Actually, that's come here and be fine. Variable, equal string trainer name and in here I can go ahead with food Name. Okay, Can I access the trainer name? If I can hear, And with printer name could be Daniel Can. It acts as a trainer and even you. What's going on? Trade this. Everyone driving. The only thing that available for me is a trained dog. The message on Lee the message. But the variable is not, and vice versa. If I wanted to access the food name and the trained old message, it's not only the sea dog, Mr So what is happening is happening because this here is the farmed locally within this braces or the bracket This is this Cope off This variable trainer name is only visible is only working and valid only well This wind to this point and the same is food On the other hand, the variable that are deformed on the top of the class Here globally they are visible in any of this glasses. So if I come here, I can access as you can see and I cant access in here for getting the dog name read. Ankle of all of them will be already fine globally. So if I wanted to define this, I can come here and good Any number between the name can be accessed within any missile inside this class in here from dental like you see now giving me an editor winner citing the name and then this. And I can also exit in here. Get me So you see now all the functions of the missiles can't see. Let's go anti helps works in the last book. I'll go ahead and greeting you. You miss it. I'll call it studying would and we need you aesthetic because we're not going to create a new instance of this. We're going to use a different cool it. Thanks. For example, say right. And now like to display this with the name, for example. I can say why and they're like contaminated with some name. Let's go ahead and form the name here. String name. Well, then good things will come here. You have the name? No, I cannot use it against for the same reason. Because I mean which is Daniel in here on Lee Available in this area? Love this area. So to use globally, I can come here, Take this. Put it in the class itself. Now I can accept it here. You can see No, I kind of Texas a year and I can look existed in here Where this When we did this in the class here the dogs classic with girly Here it's love work Here is what? Because this is aesthetic mess of aesthetic message on only deal with aesthetic variable. So I'm going to use is very well inside aesthetic message. I have to make it stick as well. So if I come here now and in the name that's accessible and again here and sex is like coming out Bendis and things happening Candace. Why? Because I did not call the function because remain here. The main functions running. But I did not call the transit. So say hi. Hi, Daniel. Okay. What is lying? Killing you for some reason. And I think the name would be Don't c Sharp will display Daniel or John. Let's go ahead and run this and see what it will be. It's Joan, Of course. Where? This Because globally it was Daniel. Okay, But a problem. When I reached down to the take home message this variable, he was override. I override it the debt in annual name here and sign John. So now, John. So I hope this was clear and he has an extra chores. 14. Inheritance: we'll come back Now it's time to discuss about one of the pillars off Children's programming, which is inheritance and hurt him simply means that a super class or apparent class or a pace class that's commonly used and heard some of the properties variables missile that it has to the subclass off the draft plans that is driving from it. Let's go ahead and see how this is done. Let's go ahead and create class gold. Anyone. Let's give you capital and would create a couple of variables. Strained Examine Cold Honeymoon name, date time. Hold anyone worse to know the edge and create E uh, mobile need animal. Let's make this variables my guest book. Okay, now we're doing this class. That's go ahead. Thank you. Like another glass Gold dogs, can you fellas? Well, exactly. Prospectus for aiming for the class to be capital. And let's create a couple of variables. For example, read that exchange. We'll collect long to the general sifts low medium of hurry. Well, it's something different. Double is easy, green or not, and let's go ahead and treat love a glass. My ankle words and it's created color verbals don't call so we're color again. Drinking bird, for example. Country, It's for now. We have three different class is not related to each other. So if I come here and create a new instance of this class anymore, you can, as you're expecting xz variables anymore. First date, able name, or even the well commissions of the animal Plus has which is eat animal. But, uh, first of them say let him create here, for instance. No and dog. Also a connected only the agreed look intelligence and is easy to trainer. The same was birds as well. But what if I wanted to make some kind of relation animal? I would like it to be the super glass or the base class, and dogs and birds would be a drive classroom. How can we do this? Let's go ahead and to make the inheritance work, we just uses simple sign here, which is the cooler and off the cooler. I will tell you that now. This glass here is inheriting from this class. I know. Maybe that special what you're expecting. You respect sensing something complex, but it's not recall if we were to you the dog instance in here. What now it has access to the variables in the animal. Remember the animal birthday? The animal name were in this class. Not in this class. Now I have access to them. And even the lesson which is seat animal. Now it's accessible Being here. Very powerful, actually. The same was birds. If I define birds had bird bird. And if I want to use bird now, only I can access a bird color bird country. And there is no Mrs even taxes. But if I go to here and thought that this would be in hurting from the animal glass and I went back here, they went back here and I can start. You think the options off the base class, which is the animal. As you can see, they are not only the bird color and the country, but also the animal birthday and the animal name. And the only function that we have feed anyone. You seem very powerful. Future Very amazing and easy to use. Well, this was fun. Here. The next pictures 15. Encapsulation: we'll come back. Now let's discuss and other biller off difference programming and the storm will be talking about encapsulation. Cancellation is a concept that points to get the data and the message that manipulate the data together and try to give them safe from the outside interference. Let's go ahead and take a look at this stable here, which is hold access, motive foreigners, and we have seen one of them, which is the public. This excess modifier I used to before and help classes can access our members, and the member can be a property variable or innocent. When we do find a member at the public. Now, the axe is not restricted. Many class can't x is this remember? But on the other hand, when you're defining, remember as protected Now you are limiting the access to drive the class from the pace class, and we'll see this in a real world example. Private, on the other hand, is limiting the access to the only class. Only the glad that have this member can access this well. Drilling, on the other hand, is limiting the access to the current assembly. Assembly is a file. This generated ones a application is compiled six straight, and we'll discuss about simply later. We have finally here a mix of expert. If I recalled protected injured. And this is mixed between the simply and the drives from the containing class. Let's go ahead and see how this works And t shirt. Go ahead and tweet. And you glass in here. I will call it those with anyone. Okay, let's go ahead. And if raise it, start to present stringing, call it, wave it variable. Yeah, probably string. Okay? I mean them. This way you can see the difference when trying to access. I mean, no one predicted string predicted, So you Yeah, journal screaming internal Babel. Now, let's go ahead and try to do the same. But with creative present. What message called for Gamble trained anymore? Like this airline ticket? A copy air alone. Come here and change. Things would be Hopefully, I mean, my that's and this is strange anymore. But we're assumed that this this four message here are doing something differently. And this is predicted between anymore. Adjective and last warm in the internal, trained on the old We'll go ahead and try to save some space for us. It's gonna have Do this. Okay, just I'm just removing the workspaces. This will never affect the executions. Now the APP looks professional. Okay? We have a classical animals with four different variables with four different access modifiers. And the same as for message was four different access 24 years. Now let's go ahead and try to create another. Glass has called this class once the left drugs and call another one. Freedom of the country. Call it caps. Expanse gets used. Okay, Now, let's go ahead and try to inherit this. We have seen in the previous victor that this Colin here, actually with the sign of hurt him. So I heard from the animals glass. Now, dog is drive from animals. No carefully stage, because watch was me. I can go ahead here and fill it That the dogs. It was cold dog. And you're here And dog actually dogs the instance. Dog. Actually, any degree you go ahead and create you voids it just just need a missing work. Feed dog. Okay. You know, let's go have use it up. Here it is. Now we can use it. The dog actually is an Aniston's off this class docks and now I can t hear what I can accept. I can access the Internet available that you can see and protected and the public. But I cannot access the present. You know this and it's going to you. Even in the messages I can see here is internal and particularly and the public but the private I cannot access. Even I have inherited the animal class, the animals class, as you can see here because this is yeah, if I change in this here mix example, public okay can come here and now I have four of them and they have the nearness. Actually, here it is this animal private. It's called private but its public because I changed it. So let's go back to making present and let's see again. Now it will is of you here. It is only the internal protected and public, and the same for is available well. He's a protected public and inter, I hope this give you a clear example. Let's go ahead and try with the cats. Cats will be inheriting anything for animals will be a separate class. Now let's go ahead. And if I'm animals Now I'm creating a new instance of time, any moves and you heroes. But go ahead and do most of the year. Pete, the cat in here I will you the animal. Let's see what can we exit? We can access only the public and internal, very old and only the internal function and the public function. Coz public is as we mentioned before, there is no limitation to the access even when we're not in hurting from this class and internal because we are all in the same a simply silent here. So it's allowed to excuse it. So this was about encapsulation. I hope it was easy to see in the next lectures. 16. Abstraction: Welcome back. Now let's discuss the last pillar of the object oriented programming glitches. Obstruction restriction means the concept or the idea that this seated was any specific Aniston's. I can go ahead and read the class as an abstract mrs as an abstract. Once I could read, The glass is an abstract. I can no longer be instance off this class. Let's go ahead and teases T shirt can come here and be class cold shapes. Or normally I go ahead and create Aniston's from it Shapes, for example, and call the chain. Go ahead. Well, what also you coming here and add the word. I'm strength to tell this issue that this will be an abstract class. Now. I call no longer King Aniston's from this. Do you see here? It's not completing. Go ahead and completed myself. It's giving me an error, and it's telling me that cannot create an instance off the abstract class. So rule number one you cannot compete in distance off have strength classes. They can come here trying to meet the normal function, say life in general and council the Threat line message say so if they fly from the district plus Thank you. How can I access this message? If I cannot greet instance off this class, I can go ahead and create class. I will call this lens and I will killing that you will be inheriting from the class soups. Now I have the ability to access this Miss would say hi through the child was drive the place, which is lights. Thank me. What happened? New Aniston's of this class and now I have access to it. If we run this, you really must try from the abstract class. But this is as before the abstract place. What if I wanted to greet the substrate message to greet the district missile? We would use the same keyword, abstract, lovely void and grow, for example. And the trick kids here that gets it. That's how you create a message as another street. There is nobody. There is no praises record just semi colon after the currencies. And now we're done. But it needs a body needs an implementation. The implant intention itself will be inside the drived or the child class. As you can see here, it's giving in Arabic but then a man that there is no implementation So let's go ahead and try to make something of intention inside the child class. Avoid grow. Can we have under some GT here? Here we call it to solve the error sold. Right, lady and its display. Why my and he wait. Okay. Still giving me an error. Can you give us? Because that's his function. We mess up this cold, Drew. And here is a drove, loved row NZ abstract class. So I need the word with the keyword override now, as I'm done writing the override old aerial guns. So here is the message drove and the child will override this message in here. So let's go ahead and read this. I will go the line. I would like to go ahead and drone from this to your work. Here it is. Hi. I'm alive and we have the letters from previous. It's high from the abstract. So this is how you can compete. Obstruct the class that I'm sure, Mrs. And how you can you will do I hope this is easy to you in the next lectures 17. Polymorphism: polymorphism. One of the most important pillars off different programming put in prison means having many forms. Angus. What? Actually, we have seen Polymorphism in the previous pictures. Remember when we created the overloaded message? When we created a different miss? It was the same name. This was one of the faces of Polymorphism, and actually it's called aesthetic time or the compile time. This is overloading, but it has one name, but it's doing different functionality and slip chur. He would be discussing about a different high called dynamic type of run time, and we would use a keyword override. And don't get confused with the overloading and overriding, and we will go ahead and see what writing instead of it. I'm reading as a concept allows you to change. Is the functionality information in a child oclock. So if I have a message in the pace class and it happened that sometimes you'll have the same message in the child or the drive class was the same name, so Mr Riding can help us to change the functionality off opposes it, and in the structure we also see the virtual override you keywords and learn how to use their conception. Let's go ahead and try to do this. I don't come here and carried in your class. I called this shapes go ahead and create only one function. Public void, grow function and trite lining message just by the simple she Okay, now let's go ahead and treat another class called this class circles. Go ahead and also define on a avoid a big void row missing here and it will have a solder trite line. I am a circle, and this will be in hurting this circles, plus from shapes. Let's go have a computer. Don't take this copy training. Oh, create resemble lies on a line and in here, the angles. We're trying angles. Okay, now we have the three before glasses. Actually, one is a base glass, which is shapes and three different child. Drive the glasses from trips, As you can see here is you are hurting from the ships. Let's go ahead and the main best of the year and try to create create you shapes the rain. I call it shapes. I knew that it would be shapes and size four. Okay. Jim didn't go ahead and sign each one. Anyone the hotel it on the index or the position zero life to create shape, top shapes and paste class and shape. One. I like to go ahead and meet circle and in shapes. Position two, and it's too. I would like to go ahead plays and lest one ST it's trying, okay? And I would like to go ahead and do for each for each. We can slip it with the fridge. Just go ahead time for each and press two times on the bottle. Innkeeper there is You can go ahead and found that this shape and shapes this shape here is very well named by before and shapes is this one, so it will go ahead and Lupus have any further information, and I will go ahead and that the shape go ahead and call the message, which is called Now let's go ahead on going to see what would be the other as against before drew message. Just playing one message, a message of change, change, symmetry. It totally ignored that Each of the charge the classes has a separate drove function, and actually, it's giving me a warning. Can you see this dream line here? That's warning That's one area. If we went to the step here released, there's three warnings fires and combine Director setting me that circle hides and herded member hold shapes group drug use, new keyword and finding was intended We will see about noon letter but actually didn't try and override I like so it shape to be displayed the same shape. So how can we do this now? Here gone the powerful keyword virtual. In order to make this override the sexuality of this I have to tell it turns that this is virtual Now I told the compiler that this message can be over ridden. So if I come here and kill it But like override dismissing now warning his gun. I love this here. Well, give me an error. She telling me that this cannot be overridden because I did not do it. So let's go ahead and try to do this. We're writing in here one more. It's a triangle over right now. Let's go ahead and try to run. This works like magic. Now it Shame has all the right Here is the first drove myself of the simple shape and the circle dysfunction drawing a circle override this here and in line and triangle is well, three portal, huh? Okay. What's up within you Remember when we used to remove this year? You could've instant. It's a computer. So does that. I have to use your word. Cool. New if I type you in here. This means that this missile will hide this functional. It will be yielding this one Here. Lets run and see the section. As you can see now the overridden here, the option of the virtual. Now it's gone. Who did you? So here is the difference between the street rewards virtual override. And you? I hope this was easy. And that was about polymorphism. So you in the next lectures. 18. Region Keyword: welcome back As reaching the end of the chapter, I would like to and use something light and powerful at the same time which he had be Keyword region. We can use the keyword reason to organize. Cool. I can come in here, for example. Hey, this year hash tag region apple. This, of course. And I can go down here. And when it's done on and region look again. And now we see that I have you sign here. I can collapse this or a planet. You see, three people can come onto here and leave some comments. This is the solution for the core. Actually, I have here the project of the car exercise on as you can see here it is rebar sold and, like, organized Michael easily. I can even come in here and start doing this inside of the class itself. Region variables. You description. This is where you should be, Claire. You were rebels and go. I have here and in the region. Great. We have a new region inside the courage in this is where you should be clearly variables. And it's a trick you can go ahead and organize. You called with this report ful and relight your okay to you in the next lecture. 19. Sealed Classes: we'll come back discussing with the glasses and in this picture we will be discussing about the sealed classes. I feel good word actually used to prevent anyone from inheriting from our class. Is I For some reason don't want any one to be in hurting from my class. I can go ahead and use the keywords. So let's go ahead and see how we came to this. Well, coming here and you find a new class. I believe it. Animal and I will create you. String very well. A cool it blame if I didn't specifying hear any accessible before the public Private, protected internal actually that they sold here is so this is defined internally as private . Let's go hang on creating a class cold bugs be hurting from any role and those would be having a streaming cold. Don't pre Let's go ahead and try to experts. Go ahead and communicate instance of class dogs And as you can see, I cannot access any off the rebels because this are present. I can come here and link this public from the same here public. And now I have for control book breathed and name going back to the soon if I wanted to prevent this class from in hurting of this glass. So this class, nobody can hurt from it. Just go ahead. And you, this something keyword sealed. And as you can see now, it's giving me an error here because this can be hurting from the same. The message is actually, says Doug's look drive from sealed I anymore. To that, said about seemed, classes assumes the next lectures. 20. Nested Classes: Welcome back. Now let's discuss the misted classes. Actually, misted means that it's a class placed inside for the class. Can you see how crazy it's getting about the classes? Let's go ahead and see help to this end. Seizure. Let's go ahead and interrogate the class animal that I use most on. I treat a couple of variables here. Lincoln. Lovely stringing. I mean, for example, they were swinging any one country where this animal is okay on and let's go ahead and they find units that class. Okay, To define a next class, you simply go inside this class in here that they would like to use. That would be the parent class off this visit glass and I'll start saving Well, like actually, you have to make it public because way to fold, it will be present. Public class. They call it looks. Yeah, look less. Let's create a couple of rebels. A string dunk read on the other streaming look, for example, and the street of the class, they call it, But look, class cats. Andi greeted only one variable in here. Captain, that's speak. I want to go ahead, and the hair can we in s 10 she ate. This class is actually the normal class or the parent class animals. It's very easy to create anyone, will you? Then we have a stints off the class animal on like an access the country animal name. But I don't see any of this dogs or cats or this variables off this classes. I feel different. Class can only access its members or functions or variables. Okay, so how can I access the dogs? Orchid gate? An instance of dogs or cats. If I go ahead and hired dogs, you see prisons. It doesn't see any glass or anything actually named laws. Even if I capital still nothing. Cats also to excess the mystic glasses. You need two under the name of the parent class and then cats or dogs here, classes inside of it. She that essentially means it's it's invested classes, gold and all the docks. Go ahead and create he Mr This and we have an instant on and I can go ahead and start using when she here the rebels nook nickname with three and again about gets equal, knew little about cats and, like am still X is the only variable caps has which is capped. So this is how you can create India with the NUS A class you know, the next lectures. 21. Static Classes: we have seen previously that we can create static muscles, and we have seen how to do this and have seen Why would we need to do this? We have seen also help to create static variables and the user study variable. In this lecture we will be talking about. This topic lasts before. Go ahead and sees this and see sure, I would like to tell you about some few rules about aesthetic lists. Studied classes can only have studied members. He cannot create a non static variable permissive inside that class will. That work will give you an energy second rule that you cannot create an instance of this topic class. This is like the abstract class you cannot instance she ate, and the last one we have seen that you can use a keyword sealed to prevent inheritance or a glass. So study glasses are also implicitly see. Let's go ahead and try this. What kind of here and make a glass called anymore. Make it stick and let's go ahead and try to create an instance of this. We'll go ahead and that the animal was anymore. You and better to telling me that cannot create an instance off the aesthetic class. So this is one of the rules that I mentioned. Let's go ahead and try to inherit from. I'll go ahead and create a class old dogs and they repaired from anymore. And again here, dogs can not brave from steady glass, just like he sealed. Now let's go ahead and try to define some variables inside during community. Very cool, probably string name and the schools was giving me an arrow because it's not study. I need to add the study keyword toe the verbal because I mentioned aesthetic message only D with aesthetic members. Okay, so how can we use the members inside of this class? If I have a function that I would like to use? Your example? Let's assume to be, have a function I'll call it probably roids. Get a wage from Animal, for example, and they will assume that the age will be. I actually have seen here. It's giving an error. Yes, it's right. It's this stupid. Now it's working. I can't console the trade line, and I will go ahead and use edict time in here. And I'll tell you, for example, that the date time the age of this animal in here, it's a dog or something. It's now and I go ahead and years and I will add Use was minus stupid to on their go here again and fitted deep time Look now year minus the year. So what? I did hear that I get the years today, which is 2017 on the years today and subjected to them from it. So now this should be 2 2017 and this is 2015 inch of meat should be giving me too. Now let's go ahead and see how can use it. We have seen provisions that we go ahead and create instance like this. This is the way that we can create Aniston's from this. But actually that's not working. As you can see here, it's giving me an error. The study class leg aesthetic. Mrs. I can go to Rick Lee and use it. They can go ahead and to General, and I have access to the name the variable and through the gate change. See right can call the missiles without creating and systems. Let's go ahead and display this and you can see spending, and it's too. And if I changed this year, too for you, do the mess now it's giving me for So this is about the aesthetic classes. I hope this cheesy seems the next lectures. 22. Partial Classes: Now it's time to discuss about one last thing about classes I promised. This is the last thing that we will be discussing about classes. It's interesting, a little bit weird, but that's interesting. It's the partial glasses. Can you imagine taking Create classes into two separate files? 35 for five? Yes, we can do this. Let's go ahead and try this. I believe this is it is and come here on the project and create class cold. I call it class one. Don't change it. I'll call it. This is cold, for example. Undervotes again 11. And I will leave. It is I will not do any study. Correct strength. Just a normal class. Then I will start having some rebels go ahead and create public string, animal color, for example and animal name in here. And get we have two very builder. Now let's go ahead and create to missives. No 11 is enough public. Wait, Get name For example On this, we'll have learned here to console right line. I told you display. My name is Max. Freezing Murdoch. Let me. Okay, Let's go ahead and create another one. I will name metals. Last two we can name it Whatever you want. Haroon. Name it animals again. Is he? I have here on glass cooled animal that everyone And now it's giving me an error. She telling me that really contains a definition for animals in there. We can go ahead now. And you, The key word question you see turns blue. It's a key word. There is gone. We need to do this year. Also Poor shield. No, this two files here at the compile time would be compliant and we would be able to use all of the features in here and all of the future. Now, remember that and the class them one. We have animal color, animal name and have one lesson. Let's go ahead and create a couple of variables here. Killer. They call it, for example, public the time First date. The animal. Yeah, even blink string with the and you will. Let's go ahead and bogus out Christie build to make sure that everything's see if they yes , built just for now. Let's go have him. They prove themselves in the main, doesn't here and creating animals. But read he animal medicines of this. Now can you guess What will happen if I press a doctor xz properties and missiles off the glass? Well, I can't do this now. I have the animal breed from the class number two and the animal color and name from class number one. Their combined again. And even if I added one more missing here that for example, do any saying Well, look, void. Say sorry because mussing actually now let's go ahead and anymore. Do it again and we have. Then you miss it in here. Let's go ahead and run the lesson which is called get name and remember that we had some text. And this message My name is Max. I'm not. So this is about the partial classes hand. I promised number classes. We will discuss something else in the next lecture to you. 23. Namespaces: Now it's time to discuss name spaces we have seen previously is that this is something called a message. And we have seen that message or placed inside of a class. Glass is actually placed inside for something called name space. So this is the container of all the classes, messages, variables, everything. This is the ran container, them old and this lines here using all of these are name spaces. Coffee Over. Over, In here. You can see here, this is names based system your dicks. This is James base reading names base eso. But why they are a drain out. Great out Because I did not use any of this year Stay focused. We have been using one of the famous classes off the famous name spaces in seizure, which is council. I want you to focus here with the using system. It's not great out as M Time Inc Russell. You see now real colors not great out anymore. I started using one of its glasses because council is important off the names based sister . As you can see here in the intelligence in, If I remove this now, it's great again so and can also exit using this year system. And this is the name space DOT console does great Like this is another way to access functions or glasses. See? Very interesting. So can I. Before, in my own name space, Of course you're gonna do this. Let's go ahead and trying to define what will name space. Let's go ahead and go out of this name space lt I can conveyed it. Considerate file working could be in the same fault like the class Great space. Go with my coun name Space way Have no news base Let's go ahead And this line of classes here don't call it feels again on a table with, like string anyone color just even. Okay, let's go ahead and excellence Greet another function. Cool It probably Boyd. Say hi. Console the right lane. This Why from the custom name space. Okay, let's go ahead and try to hexes this year. So we have the animal glass inside my own name space and we have Mr Cold Say hi, let's go ahead. And now if I could get my now I have my own ning spaces e in the sense that it means that this name spaces called my name space. Go ahead and choose it. And inside of it, I can't see. I have a class cold and will. And if I go ahead and treat, that's a glass. For example. Cold Does craters rece trainers with these animals to make this capital look better Now I have trainers and animals. They can go ahead and create Yeah, instead of this. Now I cannot access you. Say hi. Can anyone sink of this reason why I cannot access? They say hi, Mrs. Yes, you've got a great because that's not aesthetic vessel. Only study messages can be accessed without creating an instance of the class. If you remember this now so I can go ahead and very consistent with this. That it will Well, I can. You see? See? Huh? T It's working. Let's go ahead and distant exit. We have year in separate or a empty line. Its planes first land should be empty. Yes, you can see high from the system names base for interesting. Actually let me a few more crazy. I can even come in here and make in NIST intimate space. We can come in here and inside of this. My phone come. And I like to beat another name. Space inside of this group is based. I would call it, for example, um, House story inside of this name space are actually name a game sort. This is the famous you, Joe. I like it. Great. Let's go ahead and treat. Glad the glass with me. The house strike. Okay, now we have question called How historic Inside Mr Name Space called game throats. I would go ahead and read Historic. It's finally looks very aesthetic. Boy se quote Let's go ahead and say any cold You gonna go ahead and choose any coach you like. No different. There will be lures remembers. Okay, this is a coat from Zee TV show. Now let's go ahead. Actually, I defined this mission, the aesthetic, which means that I can access this message without committing innocents off this class. But first we have create excess the stones, which is invested. If I come here, there is no game strong because I have to accept through the my own names base that game strong. So it's a name space inside for him space. And then I can go ahead until the House story can then I can access Saeko preserving, defining Keating instance off this class. Let's go ahead. And from this using the noticed remembers very parcel and very amazing feature to organize Michael then classes. Well, let's think if we go that I can go ahead and time house. Sorry. Directly. If I included this year. I'm glad and feel it using my own space. Dark Gable storms is my a custom. We'll go ahead And Columbus then Then I can come here. Those Doric, the Tickle Three. Amazing, very coarse wool. 24. Structs: we'll come back now It's time to talk about something. You which is struck. It's Let's go there and see How can you distract Stretch? Actually, every useful and we can use them and plenty of situations. Let's go ahead and see how I can use instructs to create distracts music Keyword struck welcome named, for example, intact. And the race is the opening and closing. And in here I can start reading some variable him. They use the same accidentally fires the public praise it predicted and internal. They're going to be string e name. I can create another string. We don't, for example, well like you to do this alone. I don't like Silivri and I can even go ahead and to be properties. I can create public this more Opel this celery. You will make this property actually public access to this private field here. What green? So he gets Then get it will be Richard Celery has done before early. Sit with the the So are you. What will be set to kind of And that's it for now. Let's go ahead and see how you can Instant she ate this structural create variables of this time, so go ahead and type. Compli recalled this you simply and again then you So because how you convey eight variable or in distant of this strict we're like, well ahead that we now I have full access to the lea job. Simply name and the celery. 40. Love the variable Because agreeable is well, I had and that the name would be James. You know, we the job will be here. We're ready for it. Just like us. Way like to set the property of the slurry to be, for example, life. Assassins. Go ahead. Console right line. And this Play this string interpolation. You know that truthfully, it is on Z simply named I'm name on his job is again. That would be new. We no is your thing. Hillary is well, actually two property, which is fluently. Hillary. Okay, You know, that's a little time. Let's go ahead. Great and expecting in the name of James and his job is programmer and searching salary is They're says I can even come here in the strict and it's worked like one team. Is it? Yeah. Amazing, huh? Public Woods Say hi again. Let's go ahead. Right line and like by from the strict president or the Mr Instruct, it would be more. I won't go ahead. It's this year. No, I have the um, please, let's go ahead and run this and you can see I from the message district. So this is about strips. But what did it? It's just like the class. This is the same message glass actually variables with this. Excellent fires, properties and missings. So what is the difference? The difference is in the next lecture. See you in the next picture. 25. Classes VS Structs: we'll come back now. Often we have seen the strikes. Let's go ahead and sees the differences between class nous instructs. Actually, the obvious difference between class and strikes is a key word. You can declare classes with the keyword class strikes with the keyword strict, and this is very obvious now until the real differences glasses actually supports inheritance, while instructs doesn't support any kind of inheritance and we have seen, actually, how do you apply inheritance and glasses? And many occasions user designed constructors can be implemented in classes toe, for example, and do a specific job or in July, the rebels on the class. On the other hand, Struck's cannot allow you to create user defined constructors to do anything. One of the differences, the data members, can be initialized in the class definition. While the data members can't be initialized a Mr definition, you cannot go ahead and initialize any variable. You have strict well. Last distance between the class and strike is the class is reference time, while district is very time. The reference time when you create a glass, the instance or the variable that's true gated lives and something called the Heat. While this check. Leave them something called the Steak. I know this is a little bit advantage to stack and he were going too deep into this. But this is one of the differences. One last thing to choose between the class or this truck. When to use Instructor World Music class. The majority of times you will be using classes. But there is some occasions. Is the distance that you were creating are small and commonly shouldn't live. Go ahead and choose a strike over the class. So that's it about the classes and starts to you in the next election. 26. Enumerations: we'll come back now. It's time to talk about in Yuma, Rations and Immigrations actually or used to define lists. I can define the list of the week, days or the months says for any kind of lists. We'll release that I have. I can use integration to define. Let's go ahead and see how this goes. I can go here and conveyed my enumeration or my Inam, that we will see in a bit inside of this glass here. But actually it will be only visible inside of disk less. But I would like you to go ahead and make it inside of the name. Space itself goes inside of the name space. It will be accessible from any other glass inside of this name space, as we have seen before. Let's go ahead and create our first immigration to create an enumeration. We use the keyword economic here. Then I have the name, for example. I call it a week days. This is my derision now. Inside of this praises, you can start having the at least it's items, so the first missed would be the first item would be, for example, Monday, then Tuesday, because they more me So Thursday, right? A Saturday. And for many Someday then we've created offers in duration successfully. So how can we use this integration with your coming here in the main message in here? And I would read the string variable ankle a week today, and I will assign this variable here too. And one of the least items inside of the Denham Week date. Let's go ahead and do this weekday, as you can see your until the sun is telling me that you have a generation cold weekday and as accessing it Now I can't access all the glitz and for added something, even even imagine what music we have. Uh, they it's called just for example. Now be able. Nobody seems so. Whatever. I'm adding here it's displaying. And here go ahead and remove this. This would be a free phone week. Okay, let's go ahead entrance, for example Friday. But actually give me in here getting in the air there actually is that this here is you time A different time than the string. That's not a string. And I'm assigning it to any variables Time, string. And here is the era, the enemy. This cannot implicitly convert on immigration's weekday to a stream. So somebody just many diamonds like from here it's drink that's converted physically. Let's go ahead and display this display. The weekday Freddie raising Even if I changed it, make it Monday, for example. But again, that would explain one day there is another way to define a variable spoke string or use it . I can come in here and use the time week day itself. Now I have you weak data. Change this in here. I call it Week Day. So that's it's different from the weekday immigration name in here. So no, As you can see, I have even we a day in immigration time. Here. I can use it. I can't come here called a day. I will set it equal. Do now take a look. Good. Look, take a good look at this. Now, in Kelly Sense is telling me that the type off this variable in distance it should be set to something off the we day again, and I can choose it. I can choose, for example, Saturday and okay, and like when coming here and display today, it's from this acidity. So that's another way to create and immigration and its terms were very well. So one last thing for you go that this any corrections is here. Crystal injures. So there is a injure value behind the scene in here so I can access this. You see, this is the Saturday they answer today. Sink, It's number five. I think you can see here. It's telling me here it's number five. I can texas this number in here. I can come in here and that it like to convert. This will cast this into injured. And now Xing the index or the injure value. This a baby or in admiration item, you can change it Friday. I will have a different before because Fridays from So today I can't even come in here and a sign my own value and govern here Friday. I can't make it 40. So today I'm gonna make it. On Sunday, I make it 60. Let's go ahead and write for is the Friday and it's 40. So I righted the default settings. Come here. So they from it in 16. So that's it about in generations and original, very partial. Re handy Annual. Definitely be using location. I hope this is easy and fun. Syrians and ex pictures 27. This Keyword: we'll come back in this lecture. We will be discussing some you key word, which is this skewer. This actually had a lot of uses inside seizure. But this lecture will be discussing one years, which is Does it can be used as a reference through the current instance of the class. Let's go ahead and see what this means. What? We go here and committee. He your class local with Kristen and the elder form String. Well, the first name This boy, the fault is present String. Last name. Let's go ahead and create a new message to display the name. Okay. Very simple. Inside of this. Miss it. I will be using a council. That red line display the name, actually, Jersey. First name. Well, just come company space and the lesson. Well, I'm here. Thank you than you overloaded message will be taking to the strings. The first name on the stream last night. Okay. You know, we've been going here. You did When you construct her. She don't understand it two times on that bottom. We have constructive. Oh, that the first name. I am just initializing the default for the first name of last name I will make the default as looked. Yeah, it's mind only last name eightfold stream that empty due to different values. Okay, so if I come here in the mean message and try to use this person thing Cool it, person. Just a name of a class or an instance of the class. You could eat anything. I have access to the display name with the two and mrs in here, The one without any arguments and one was to go ahead and try the 1st 1 Now it is playing, not deter mined. And listen because it's here is the value from the construct in the first name and the last name. What if I assigning them? Give them a value. So games for for gamble, my son. Now let's readiness. And as you're expecting in Shelby, displaying James Morrison, she stole the lead. Perfect. Now it's all right with sittings in the constructor and went to this overloaded message. And this way, the new name. So what if I wanted to access actually, in this function here, in this mess of everything to excess, this first name on this listening This could not have him because as you can see here. This is the same name, the same variables at this. So how can I Texas this here? This comes in handy. I can use this. This actually refers to the current distance off the class so I can keep X is the first name and last name and the functions or the message inside of the class. So let's go ahead and add. Listen, this like this and this this the tress name and this look last name. So the first time I'm maxing only the first name and last name and the second climaxing the instance. First name of this class ends Aniston's last name of the glass. Let's go ahead. And he's a difference. Never see the 1st 1 actually access the values that they busted a message. And the 2nd 1 allowed me to access this in here. So this is reasonable and has a lot of users. And give your Avery a fast way to access the instant self. So if I change it this from here, I can make it. Take it. And here, for example, David. When readiness. Now, David Smith and foursome, That's it about this keyword. We will be using this in the next lectures. So this seems an extension 28. Interfaces: Now it's time to discuss interfaces. Interfaces actually is one of the essential and interesting and concepts and world of program. And if you're going to a life where job, trust me, you will be definitely asking about interfaces one way or another. So let's go ahead and this one interfaces. Interfaces actually contains definitions for a group of related functionalities. So we have a sent off declared methods or properties or variable evidence, all the declaration. There is no implementations in the interface itself. Then a Class one instruct can implement this interest, as we will see later. Okay, so think of this is a contract. The contract between interfaces, a glass. The interface port is caring about the worked what will be done, the glasses or the child, the classes, the driving classes is caring about how this is going to be done. Okay, so it's a contract between the the driving class or the child of plants. And the interface that's for itself is caring about the what work while the child, the class caring about the help for the country. What's ahead? Mt. Help is goes T shirt. Let's go ahead and stored. Creating offers, indices inside off outside of class here, let's go ahead and create in the face using the keyword interface. As you can see, it turns blue, which means keyword. Usually it's better way good practicing that you different interfaces with the capital. I then time, whatever the name, so I can go ahead and call it into phase dog commands. Okay, that's it. Defenses are public like I'm not even coming here and tie private will give me an error so or even protected cannot be protected. Okay, The only empty which is bubbling by default or you does the word public and it's still 34. OK, so inside of here you can come and tell it that there will be a function. It will be a void world. It's called, for example, state at the command for the dog. You see, it have only declarations off the functions that can have another function cold. Sit one cold the tech because his dog is okay. So if I wanted to community body or implementation for this instead of their faces, what could be an error? Give me your face. Members cannot have a definition. Think so is only the declaration so I can also coming here, Anthony, that they would be property called. For example. Don't name doing it. No actual implementations. Only declarations. Okay, Now we have created our first interface, which is called I don't commence. Let's go ahead and see how come use it. You can go in here and create a class called dogs. A normal class family can go in here and create a year. Believe it. Thing no read variable. So how can I collect this class here to this interface? Simply using the colon. You think the color of the insurgents, the symbol of the curtains. I can come in here and elit. I don't commence now it's working. I know this is giving me an error right now, but I tell you what about this era. But now this is how you define this. We connect this class to tell it that it implemented or hurting from this interface this air. Because actually I must. And you must You remember about the contract I must and defined or create implementations for this function is here. Dogs doesn't implement interface. I recommend Stay said take and the property to name. So it's complaining because there is no actual implementations with this. Take a good look. I can come in here. Make public void. Stay one. Sold through them with lose things. Look is staying just a year connection and the errors New. More state of the station. It's removed from the list. Let's go ahead and do list the last of them since yoga's sitting Thank Carol, Doug is Take it. They're the errors or gun. Only one, which is the property. You can come in here and the bullets change. The name must be the same names. Of course, Now there is a gun and have created the glass successfully which implements this interface so they can come here in the miss It and Cirque using dogs don't dogs your dog and your instance or object log man liking well it to attack example. And now there was a taking. Okay, you cannot come in here and create an instance of interface can come here and choose. I don't commercials. He conceived the intelligence telling me that tourism interface cold by the commands but I cannot create instance of this. It's not letting me to talk you nivel created. This is giving me force. And there. Okay, What if I wanted to create a class called animals? All the examples that we have seen before? Animals and animals. Actually, we'll have a couple of rebels, one of them string. Really? Well, I mean, okay. And we will have only one one shown cold. Okay. All right. And what would be going from the animal to close? All right. From the rose close. What if I wanted this class dogs to be inherited from the animals and implements the either commands? Can you do this? Yes, Squares. You can do this. But the class that you will be inheriting should be, but first so I can come in here. And Philip animals. Coomer Tyler commands. She now it's inherited or a child glass off the animals and implement the either commands. But enough to the interface it Selves. Give me an error. We had the ITER based glass. Anyone must come before any interfaces. Thank you. And citizens really helpful. It's true. Isn't a car May we see so we can go over here and even access to the same high message and the so I think. For here, dog dog. So you know she before that I have access to all the base class functions. Now One last thing for you. I can even create a brand class for the eye dogs commands and believe it's crazy. It's getting crazy now. I can come here and for the public interface. But why on the roads? Comments. If that's a different commands for the animals, J or let's change a trunk. Women's by animals. You would like this, and that will create a declaration from us. It cold, for example. Well, and we'll make this child make the eye Dogs commands. Child of the eye Animals interface again. The amazing Kohler my animals like and those you see, It's working didn't give me there, and I can still nexus full of protection. Let's take a look at this now. It's giving me an error. The implementation itself ends up last August giving me an error and gets it. Yes. Now we have one message. Was a implementation which is run or in the air, so telling me the dogs does not implement in the face member I animals credit. Okay, let's go ahead and define it Lovely, Lloyd consoled. Tread lightly any well is running. Okay, Go hand dry. It the visit? No dog note. Anyway, it is running pretty amazing. And, uh, things very interesting features one last thing before we go. It's a very good information to know that I can. And here it. And this glass, for example, looks from multiple interfaces. If I have another interface, I can and hurt from it. Even it's totally different, I think. Return interface. Hold, for example. Cats. That's a beautiful home, drainer. Something I can come in here and even the ritual of the trainer. Okay. But I cannot inherit from another class only one glass like an and heard from. So multiple inheritance is not allowed and see sure as I'm recording this, but multiple inheritance from interface is hard to believe. Okay, that's it about faces to use the next lecture. 29. Interfaces VS Abstract Classes: we have seen previously. How can we use interfaces and see? Sure, but if you think about it for a second interfaces, actually every similar. I'm strict glasses. Let's go ahead and trying to see similarities and differences between buses, most interface and abstract glasses. You cannot create instance of them directly, and we have seen this before. It will give you a syntax error. If you try to do so, most of them must implement all six members assumed that we have three message of functions inside interface or an abstract glass. You must implement them old inside of child class. Otherwise, it will give you some things there. Both of sinking contains Evans missives and properties, so you're basically doing the same thing in a different way. You're in different technique. Let's see some of the and differences between bottles interfaces. You cannot have most of implementations. If you would like to implement a message, you must do with him as a child class. On the other hand, in the abstract glass, you can have actual Mrs implementation you. So in the abstract, the class you can have it in the child a glass for in the abstract class itself. It's too interfaces. You can use multiple inheritance you can in her. Then we have seen this actually, in the previous lecture that we can inherit from different interfaces, streaked glasses and all of the glasses actually came in here. It only from one place. Multiple inheritance is not allowed. Incision interfaces actually come up access or use the accessible the fires. Everything's that's your bubbling. On the other hand, you can use excess water. Forage normally with abstract class. One less thing that interfaces cannot contain variables. If you go ahead on trying to create the very basic Grable's inside of interface, it will give you an error. Why Didn't restrict Blast? It's a glass. Of course you can have normal votes. 30. Exception Handling: Now it's time to discuss exception handling. We have seen exceptions. Actually, many times we have seen it. When we try to divide, you know, zero. We have seen it when the user give us a wrong MBA, and in this two cases we have runtime error over the crash screen. So exception actually get a runtime errors that happens during the execution. For program exception handling. Give us the way to transfer the controls with one point of program to another. Trying to soldiers raised issue. Exception actually is based on this keywords. Try catch. And finally, Dr Look actually contains a set of statements or code. You are expecting to have some kind of problem catch early of a hand from its name. It catches the error and in your store dealing with the air. Finally, look, actually contained the statements instead of code. That's gonna happen. Whether the exception happened, you can start diving the exception handling. Using this world, try and catch only, or you can use dry and finally, or you can use the streams and try catch and flavor. Let's go ahead and seizes, so I come from in here and they kind of picks close to zero in the foreign. Why subject is free? Inaudible? Well, it does. You said it. Do you okay? Yeah. Let's go ahead and trying to divide and three for the way by the X and let's actually try to display this. The result is, and the day as you're expecting, grasses screen, always the exception and 100 100 exception. Okay, let's go ahead and try to apply what we have seen in the presentation to the top Doesn't the good that I am that thing or suspecting that it will give me an error or its were raising their. So I'll blade this inside of tribal and this is how you decline and try. Just try and this place is or brackets and your gold inside of it. It's giving me an error now telling me that it's missing a catch or finding, so I'll do it with the cats. Let's give a total this time, and here is the end. Now let's run this. Actually, it's killing me. Result is zero. Now the error or the runtime error has bean coat, and the result is this area hiking go further and this Oval police, it inside of finally look in here and there is exception. Actually, I can come in here. And that's the exception she here to Plus he, for example. Now I can go ahead and display the area. So So if something haven't here, is and the e here can have shape. Have the message E, which gets the message is that describes the current exceptional, That's what Heaven Klopus Royal. Now let's call him. Forget it. You see here Errors attempted to divide boys. You now very amazing to get the air in here so I can even come in here and just that. But whatever code I want to do, coming here in the finally and on this, the result is you. So what have I changed the X value and made it, for example? Street And this on me kid by no, that's from this. The program child, be running very Texas films about any errors or exceptions. So years Result Street. But if I'm back to zero, it will go on here, as you can see. So this is how use exception handling to use the next pictures 31. Exception Exercise: Now it's time for a small exercise about exceptions. I would like you to go ahead and division operation between two numbers. You will be taking this to numbers from the user. I would like you to go ahead and eliminates the runtime errors. Or the exceptions user may give you a wrong number. Character, for example, Usually try to divide by zero. So I would like you to go ahead and do it your own. Okay, I hope this is easy. Let's go ahead and try to do it together. Don't first old B two rebels first that hunt worst and for his number, set it to zero and again thinking number today to you on a double, which will have the division result now in here. Let's go ahead and try to take in which from user First, it'll be displaying a message. Let the user know that he should. First number concurs the first no fears number. I don't think it really Council freed loan. Remember, we need to casted to lend worship talent now the second number, but I have a transitive second number. Okay, let's go ahead and believe the results be a message. Results for equal. They've result And to do the corporation itself on difference number divided by the second number. Okay, Now, let's go ahead and try to win this and a realtor. It's giving me an error. And the exception, actually, school format exception. Who will be using this in a bit? And if I try to hurt, it was 050 The divide. Raise your exception. Okay, let's go ahead and try to use the dry. And so this code here, I will place inside of a tribe plucked. Go. This may result in an error. Okay? And I follow it with cats on. Then I'm coming here and playing message, so I mean that there is an error. There are pollute. Okay, It's gonna have the numbers. Now I will into realtor. Now you see the message eight. Or happen. And if I tracker divided by zero now, Aero happened again. Okay. If I try to go normally, you go with any problems? Nine. And street, for example, was old equality Okay? Now, I would like to, uh, make it more clear the message, the error message itself so I can come in here and this year, so The first error is for the exception is Divide boy here. I like coming here. We do it. I cannot do it. Bari zero Like I had another catch, actually. Change this, Not divide with here. This who would be called format exception. Okay, well, that's my said Drew Abusers that it's he in of, uh, lived. Okay, Notice. I want to go ahead and try this now, so I will be trying to send zero cannot divide by zero, and we're in again an injury. Wrong, m, but now invalid. Two different messages. Okay, You can keep adding many catches or exceptions here to display different messages. Okay, but I will come to me. Actually, I would like this program to keep a working unless I give it. Yeah, e right. Answer the correct answer. So when it goes in here, it remains up to this. And when it goes in here, it terminates after this. What if I want to this program to keep going unless I have a correct results? Okay, I can do this one many if ways I will use here e something need that's not very commonly used, but let's go ahead and t so I can come here before this Try get it story again. This called you reference and I can come here. And after the message is displayed, I used the key word Go to. It's not very commonly used. It's not bad to know about it. And now, two years and again here on the ears and raised and the message displayed Don't like you to go ahead and start again. Now let's go ahead and run this So when I have wrong M But now the message invalid MBA to this way and again. Still in the first, for example one. And do now I can divide again. Do your and it's telling me that I should enter the number again for local I try nine industry and the result is three and the program is terminated. Okay, well, less thing if you remember, If we try to divide life and two, it will give us 22.5, which is but wreck go. This is a never to need to cast it in here. Double again here. He asked this second longer it's gonna cry this funds to 2.5. That's quick. Okay, I hope this was easy for you. So see you in the next pictures 32. Composition: as reaching the end of the shepherd. I'd like to introduce some other concepts about object program. On this lecture, we will be discussing something called Was it we have seen before? That there's something called inheritance. And if you some comfort and curtains can be defined as it is a relationship between objects , so we can say that the core is a vehicle where core is the child, the glass also the parent glass or the basic last vehicle, as you see here in this example. So we can say that the court is a vehicle, so Okay, what about composition? Composition actually is designed as a portal solution between objects, so we can say that the engine is a port off a car. Look at this example. We have a glass gold engine, and we have a glass gold core. So glass engine is the next enshi ated inside off guards. Okay, that's why it's cold e port off. There is two main points that we need to notice here. 1st 1 is that the lifetime of the child instance. The engine a glass, for example, is dependent on the owner of the peace class. Child's doesn't have your own life. There is no life cycles for the engine class without with the carcass another point here that the parent, if it's deleted, all the child's objects will be also lets over. Cory's lated moved or destroyed for in reason. The engine also class will be and leading. Let's take another example. Assume that this is a bank in here. And most of banks, of course, have different branches in different cities. Different addresses. But if we deleted the main bank or removed or destroyed or it's not doing any business in world, the branches would be removed. There is no existence. There is no meaning for the French to exist without the bank itself. Okay, so that's it about composition to you and Senator Pictures. 33. Aggregation: we'll come back. We're still discussing more about object oriented programming concepts, and in this picture we will discuss something called aggregation. Aggregation can be defined as he has relation between objects. Let's take a look at this example. Teachers and addresses. Each teacher must have an address. I succeeded. Was him or her course. But if you consider adviser person, it doesn't make any sense of each address. Must have a teacher, Let's think. And you been looking here? Future can have an address. School itself is gonna have an address a student also can have on others. So, as you know, we have a glass addressing here. So the teacher glass can have he instance inside of it. Old address to see Mazza School, the same as a student. There's two main points to considering here. First point the threes and ownership of the instance, which is, for example, in this one year the teacher of the ownership of this address at a specific time. It was it was the teacher gonna change his or her address. But at specific time, this was the parent of the Citrus. And the school, of course, have this address and its owner and the student is the owner of this address. The second point. There is no life dependency on the parent class. The address is not dependent on the parent class, which is T shirt here. Or this old is a student so sensitive of segregation. I hope you get it seems the next lectures. 34. Association: That was the last concepts that I will be discussing with you about Object trims programming, which is association. In this lecture, we will be also comparing between three concepts composition, aggregation and association, so association can be deformed as the using relation between options. Let's take a look at him. Teacher and student. A teacher can be teaching many students, and the student may be learning from many teachers. Those There is two main points to Nazi 1st 1 that there is no ownership and the 2nd 1 is there is no lifetime dependency. The teacher is not dependent on the student and the student is not dependent on the teacher . So let's try to compare between this tree off the destitution. So association actually is the relation between objects can be defined, as is at were using relations. Most also have independent life cycle. Each objects always their actions and what effect each other because they are independent. So in association there is no ownership and there is no life dependency. Okay, aggregation. It's a specialized form of association, generally defined as hands relation, each object in creation as an independent life cycle. There is ownership between objects so it's different than the association. There must be an owner in s decision is there is no ownership because their relations. So the last form is the composition and its specialized form of segregation. So composition in the part of the aggregation and aggregation is a born off the association , as your representative exists circles in here. So composition usually signed as a port off relation, as we have seen in the engine and gardens and child objects have dependent life cycle because there must have or placed inside of a parent class. There is ownership between politics, so composition. There must be an order and there is a lifetime and dependency on the parent glass. So I know there is some confusion and hear about association, aggregation and composition. But I hope this presentation clears for you Don't see in the next lectures 35. Summary: congratulations. You've made it to the end of destructive summing up what we have been discussing. We have seen the seal, the glasses, and how can we prevent our glasses to be inherited? May have seen the study last night, as we have seen the mystic glasses. How we can compete, blesses was in classes, and we have seen the craziness of partial classes that we can create glasses on multiple files who have seen also the name spaces and we've created are only Spain's, and we have seen the wind off the glass, which is a strike, scenes of differences and the similarities between instructs on classes. And we have seen the magic e word this and also we have been discussing about interfaces, and we're seeing also the difference between the interfaces and the abstract glasses. I know they're a little bit similar, but there is some difference between them, and we have seen also the exception handling. And how can we have the run time errors in different ways? And we have seen the go there a little bit confusing. There's the composition, segregation and estacion. I hope you enjoyed destructor had I did and see you in the next chapters to you