7.4 Composition Challenge
Hello everyone, in the last video, we saw what the composition was and in this video. The challenge is to create two classes "Bank" and "Employee" Both classes will have a private property, "name" which is a String A builder and a "getter" this time not a toString In the Main class Create an object "Bank" and "name" Axis So a reminder to create a Bank object is called the "Bank" class. As variable name "b" new Bank() And to make the getter We take the variable bank It’s all After creating an object "Employee" as Bob name for example You can choose any name Then display "Bob is an Axis employee" So are you ready? Let’s go! I hope you managed to make this challenge. Now we’ll see it together. First, we will create the class "Bank", a private property String name Then a builder Alt + Insert To quickly make a builder and a getter The same Alt + Insert, then "getter" We will do the same for the class "Employee". So, we will create the class "Employee" And that will also have private String name A constructor and a "getter" Now we are back in the class "Main". Then, we will create the object "Bank" Bank b is equal to new Bank In brackets Axis And also an "Employee" So "Employee" As the name of the variable emp new Employee In brackets "Bob" Now We must display "Bob is amplified by Axis" So we have to use the getters, hence the gettres in both classes. It was a very simple challenge. A small challenge. On composition, you have everything. Tell the next one.