9.2 Interface 2
Cliquez içi pour plus de vidéos disponibles sur notre chaine youtube !In the previous video, we started working on the interface and we made an example on the landline. So let’s continue with another example By creating another class Mobile phone that also implements the interface "ITelephone" Then I’ll create a new class java as name Mobile phone Is-What I’m going to do now is copy some of the code from the landline phone and paste it into the mobile phone. We just need to make a few small changes. So we’re going to add a Boolean variable to see if it’s turned on Because generally you can turn on is turning off a mobile phone. as opposed to a desktop phone would normally be on all the time. So, private Boolean active Initially we will set it to false. Then we’ll change the name of the manufacturer. In the "turn on" method we will set it to true And change the message The mobile phone is powered on. In dial method We will configure to make sure the phone is turned on. Before we can call. And if that’s not the case we’ll put a message So, we’ll put if that’s lighting It’s ringing. So, we replace the message Au linked from office phone to mobile phone And otherwise a message The phone is off We will also change the method "answer" and "phone call". So, in the response method, we just modify the message. In the "phone call" method here we check if this is our number. We’ll also check if the mobile phone is on. Then we change the message. Otherwise, we will display a message "The mobile phone is not on or different number". Now, we go to the main class and we do a test to see if it works well. We copy/paste. We refill by mobile phone. And change the numbers. Then we launch our program. As we can see, we have our information. That was it for this video I tell you next time!