Monday, 14 November 2011

Java: Texas Hold Em (4)

Today (Almost tomorrow >_>) is gonna be short, mostly because its so late! We're gonna start off with the Hand class! Over the next day or two we'll finish it up, and then we can move on to something else! Hand Value, or Player or Table, I dunno, we'll see. Let's get this show on the road:



Starting off really simple-like. We have the max cards you can have in a hand, the actual cards of the hand, and the actual number of cards currently in the hand. As in the comment, so I guess that was a pointless sentence.

Also, we can't not have an empty constructor, because then we can't construct without parameters, since we're going to have a constructor with them. It's silly, but there you go. I don't see many potential uses for an empty constructor, but just in case.


This is our main constructor which takes a collection of cards. Basically like a list, can be iterated over. Which is what we're doing on line 32. Line 33 is calling a method which I'll show you tomorrow, since it's a little big, but what it does is add a single card to the hand.

Finally, because it's small, I've included the size() method, which just returns the actual number of cards present in the hand.

That's it! I've just been really busy, so sorry this had to be short and poorly written :P See you tomorrow!

2 comments: