+ 2
Is we can use our own method for getting and setting private attributes or methods
Why we can not or should not use our own method for getting and setting private attributes or method.Using self created method also works for getting and setting attributes and methods so what's the problem in that.I had used my own method name. For Example: https://code.sololearn.com/cLvAzJJkP2Um/?ref=app
2 odpowiedzi
+ 2
Akash We can make our own setter and getter method of members. There will be no issue but we can't recognise that what data we are going to set or get. For example as you created your own method which is not on the name of members and only you know that method works to set data for color but if other person will come to work then he/she will not get in which setter method we have to use to set data. There will be no problem for single or 2 or 3 members but if there will be more than 10, 20, 30 then it will be not good to create own method for each members.
+ 1
It's just an agreement like in the main method the parameter will be called args but it actually can be called however you want