Monday, 2 January 2012

Java: Texas Hold Em (32)

Hullo! Finishing off the table class today so tomorrow we can go through a tutorial of the Map class. After that, we'll be messing with the ConsoleClient to complete our functionality, then put aside a few days to test it all out so we can be confident that we're set to move onto the GUI and so on and so forth!

There's more Map work in today's code, but it'll all be made clear soon! Until I do go into detail, think of a map kind of like a dictionary that maps meanings to words. The word in the dictionary corresponds to the key of the map, and every meaning corresponds to a different value for that key. Enough to tide you over?

Here's the code, then! This method grabs the active players, mapped and sorted based on the value of their hands:

The only thing I'd like to make note of in this screenshot is lines 337-340. The reason this is being done is that we're, in the next lines, adding a player to that variable. If it hasn't been initialized on line 335 because there was nothing to populate it with, and we try to add things to it, an error is thrown!
Otherwise, probably self-explanatory, if you look at the commentary! If not, let me know!

For our second screenshot, we'll probably need a little more explanation, even with the comments!
First is the parameter list for our notifyMessage method. It could easily have been "String...", but Object means we can use anything. We can now put as many arguments as we want into this method call, as long as we have 1 for the String message part. All other parameters are passed to args. Looking back on previous uses of notifyMessage should clear any confusion up!

And uh...that's it! Let me know if you need anything gone over or clarified, any and all questions welcome as well as general commentary, and I'll see you tomorrow for a short tutorial on Maps!