0
Whatâs the advantage of using class methods instead of just methods?
I understand that they are for an instance of the class and not an object, I just donât get why they would be used.
5 Answers
+ 4
Nick OOP opens a whole wide new world of possibilitities for you. Think of it this way. The language has data types that you can use like int, String, double and so on... OOP allows you by creating class to create a new datatype for your needs.
Let's say I am coding a game and I have several players. Each player has a name, and then they have the number of points that they win, and maybe I have to keep track of each player's turn... What I can do to make my life easy is create a class Player. Now, I have a new data type and I can create many players, just like sometimes you initialize many int or String in your program.
And now everything, player name, player points and all that, is just dealt with through the Player class.
OOP is awesome stuff!
+ 3
Think of similar reasons as why you use object variables and class variables -- to address class-relevant events.
+ 1
cyk Thanks! :)
0
Ok thank you, Iâm going to need more experience with classes to be able to implement that though
0
Kuba SiekierzyĆski What are the advantages of using OOP and Classes?