6.3 OOP Method, Assignment and Builder

Hello, in the previous course, we saw the objects and the creation of our city class. In this course, ... we will deepen the creation of our City class, meaning that we are going to introduce the notion of attributed and the methods of ... our classes in the previous course we specify the state and the behavior of our classes.The states correspond to the attribute ... and the behavior, these are the methods of our class.This course is similar to the concept of encapsulation, its principle is ... to group in the same computer object the data and the processing that are specific to it.During this course and the ... following course, I’m going to use the themes assigning and method or function, but before I start introducing the methods ... and assigning them You have to know that afterwards, we’re going to build or instantiate our city class to create ... objects, we’re going to need a builder,A constructor in a class is a method that will allow us to build ... our object.You have to know that have Java, we already have a default constructor. But I’m going to show you how to create a builder to create a builder you have to put public followed by the name ... of the class and then the parentheses and the acollade afterwards I’m going to show you that in the ... parentheses we can put the parameters but why we put it public since the builder will allow us ... instantiate our class the city is-creating objects other classes will have to have access to our constructor ... so we will put public to have a direct access to our constructor if we were to put private ... we will not be able to access a constructor thing from another class and in the construtor we will display the name of a city for example Paris we will now create our object So to create the object we use the main method it goes our starting point, we’ll yell a class ... and call the main method to instantiate our city class so creates an object and you have to put the class name ... then you choose a variable name since it’s going to be a City variable, ... In previous courses, we have declared variables, first the type and then in name of ... the variable and you will put new equal the class name in parentheses, for reminder, an object is ... a class instance, Objects are created using the builder. This instanciation is done thanks to the new operator followed by the name of the class to be instantiated here City and ... parentheses,Afterwards, we will introduce the parameters of our manufacturer. It is important to know that when an object is built, the data that constitute it are placed in a place in the ... memory that cannot be directly accessed. We can however recover a reference of the object, that is to say the access point ... in memory of this object so here our city variable 01 contains a reference of our object, that is, from our ville01 variable we can ... access the method and the attribute of our class, but of course it will be necessary that our method or attribute ... are in public to see access. now we can compile our program and in the terminal we will see Paris display