7.10 OOP MASTER 2
So we will continue with our Hamburger app. Now we will create a girl class that will be Deluxe Hamburger. The deluxe hamburger comes with fries and drinks but no additional additions are allowed so we will create the class and that will inherit the hamburger class. . Then we’re going to create a builder with no parameters. So, we delete all of that. So we’re going to call it "luxury". As a sausage and bacon name. And price 14,54. Type of white bread Then, as expected Chips and drinks. The first would be great. Addition hamburger(). and as a 2.75 price. And the second super. Adding hamburger2() Drink and as price 1.81 Now let’s go to our Main class to create the Hamburger Deluxe Hamburger Luxury object. as variable name "db" is equal to new deluxe hamburger So, db Detail Hamburger. And then we can launch our program to check But, now no additional additions are allowed. We can’t add ingredients like that so to do that you have to go to the deluxe hamburger class. To add "Override". So, Alt + Insert As if to add a constructor. And we choose "Override". And then we choose both methods. AjoutHamburger() And inside we delete "super". Because we just want to display a message. Then we go back to the Main class to try to add an ingredient so we’ll do it randomly. And we launch our program and as we can see it’s impossible to add another ingredient. That was all for this chapter on object-oriented programming In the next chapter Let’s see abstract classes and interfaces Go! I’ll see you around.