Jan-12-2018, 07:13 PM
(This post was last modified: Jan-12-2018, 07:14 PM by Gribouillis.)
(Jan-12-2018, 06:47 PM)mpd Wrote: Why? What benefit is gained by using classes here instead of methods?There are two immediate benefits:
- Classes is the tool that generally avoids struggling with global variables management. Using instances creates a new space where names can be defined and shared between different functions.
- I guess @mquesnel's project is to add new features to his/her games and it's going to be much easier if one uses classes from the beginning.
If you look at the code, you notice that I achieve the OP's objective to play the second game if the first one succeeds, and I do this by using an instance member, and no global statement. You can do the same with a value returned, as you suggested, but it is less extensible.