We were given an assignment today that required us to build a very basic racing game. The idea was that a user would set a number of racers which would then race against each other. The entire process after a user inputs the number of racers would be automated. We were given a skeleton of code to work around, and the very first thing I noticed was that I had two classes, the game itself and a Die class which would randomly generate the distance each racer would take per turn. And here was my problem. How do I get methods from one class to talk to another class?(Aka sending messages between classes?)
A Traditional Call
Up to this point in my developer life, I've dealt with method calls in one class by creating an instance of the class and then calling the method as so.
What I didn't realize was that not only can you create an instance of a class within a different class, but also you can method chain onto these class instances like so.
After coming to this realization the problem became much more manageable.