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.

29th Apr 2018, 7:36 PM
Sprite
Sprite - avatar
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!
29th Apr 2018, 10:34 PM
cyk
cyk - avatar
+ 3
Think of similar reasons as why you use object variables and class variables -- to address class-relevant events.
29th Apr 2018, 7:41 PM
Kuba SiekierzyƄski
Kuba SiekierzyƄski - avatar
+ 1
cyk Thanks! :)
30th Apr 2018, 10:39 AM
Nick
Nick - avatar
0
Ok thank you, I’m going to need more experience with classes to be able to implement that though
29th Apr 2018, 7:45 PM
Sprite
Sprite - avatar
0
Kuba SiekierzyƄski What are the advantages of using OOP and Classes?
29th Apr 2018, 10:15 PM
Nick
Nick - avatar