Whoops, lost track of time, but here's the second weekend post! We'll keep this one short too, and tomorrow we'll move back to the standard posts. One more week with weekend posts, then back to the 5/week schedule.
Working from the pseudo-blueprint we constructed yesterday, let`s get through the instance variables and the constructor for the HandValue class:
Right off the bat, on line 3, we see that our class implements Comparable. While this isn`t strictly necessary, since we can put in all the methods from Comparable ourselves, it does make it easier. Extend a class and have all its methods put in by your IDE, or at least have it complain until you tell it to put all the methods in.
Lines 5-7 contain all the important information the class needs. The hand that`s being given value, the type of the hand (Being evaluated in the constructor) and the actual number value of the hand.
Lines 9-14 hold the constructor, which is pretty short, as far as constructors go, taking the hand in question as a parameter. The class hand is set to whatever is provided on construction on line 10, line 11 evaluates the hand, line 12 gets the type from the evaluated hand and line 13 gets the number value from the evaluated hand.
Easy, right? That was actually shorter than I thought it would be, but its Sunday, so yay. Back to Skyrim for me! I just got Dawnbreaker, and want to test that bad boy out! See you tomorrow, questions and comments welcome!
You're working overtime with these weekend posts haha.
ReplyDeleteThis was interesting.
ReplyDeleteThat's always good to have things go better than expected. :)
ReplyDelete