Okay, never mccd; I feel really stupid! I changed it to boolean ace=false; and all is well now.
Have a great day, Alex
----- Original Message ----- From: Alex Parks <mehgcap@xxxxxxx To: programmingblind@xxxxxxxxxxxxx Date sent: Sun, 02 Dec 2007 21:33:23 -0500 Subject: another java question
Hi all, Sorry, but I have just one more question about this blackjack program. For some extra credit I can include a function that adds 11 to a hand with an ace when the total of the hand is below 11 and adds 1 with an ace when the total is more than 11. I have this function inside a method called getHandTotal(). I use a boolean called ace and set it to true if the adding loop encounters an ace so that, after the loop, I can use an if statement whose condition is that the handTotal was greater than 11 and ace==true. Inside this I subtract 10 from the hand (same as subtracting the 11 that was added in the loop and then adding the one I want). The problem is that the compiler says that ace might not have been initialized, but just after starting the method I say boolean ace; Is it because I am setting ace to true inside a loop or something? I have no idea why it won't work. All times I call ace it is lower case. I have tried just saying if (total>11 && ace and if (total>11 && ace==true but both result in that same error. Thanks for any help.
Have a great day, Alex __________ View the list's information and change your settings at http://www.freelists.org/list/programmingblind
__________View the list's information and change your settings at http://www.freelists.org/list/programmingblind