6.20 OOP Exercice-2
Hello, welcome to this new we will continue on our challenge, we had arrived at the second step "finally, create another class, specific type of car that inherits the car class. A private property, second insurance property. Then we will generate the builder. And in this method we have only one Peugeot car, so we will put the values of the Peugeot car. For the size we will put it to 1.50, SUV category, wheels 4, door 6, speed 200, manual true. Then we’ll do a method to accelerate. We will put in parameter the change of speed, that is to say if the user wants to put 1,2,3,4... Then we will create a variable that will contain the speed change. Get the speedActuelle plus the speed that we are going to have in parameter, then I will make a condition if change speed is equal to 0 then we make another condition if changeVitesse is equal to 0, we are going to use the changeVitesse method which will take as parameter the speed plus the current direction so get current direction Now that we have the accelerate method found in Peugeot, we are going to give it a try, we go in our hand then we will write car Peugeot and for insurance we put Macif. We will call the speed method, we will set the value to 20, we will copy the program and in our terminal we have the change to 2. We will copy the program Voila, The condition works very well and the methods we put in vehicle and car are calling correctly I hope you have understood all the steps we take.