RE: another java question

  • From: Alex Parks <mehgcap@xxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Sun, 02 Dec 2007 23:23:32 -0500

Out of curiosity, why can you say
int b;
or
char c;
but you must give a boolean a value?
Finally done with blackjack!!!! I will have no more questions with which to bug you all... until the next project.

Have a great day,
Alex

----- Original Message -----
From: "Sina Bahram" <sbahram@xxxxxxxxx
To: <programmingblind@xxxxxxxxxxxxx
Date sent: Sun, 2 Dec 2007 23:16:07 -0500
Subject: RE: another java question

Initialize  the boolean to something, for example: false.

Take care,
Sina

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex
Parks
Sent: Sunday, December 02, 2007 9:33 PM
To: programmingblind@xxxxxxxxxxxxx
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
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind


__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: