Re: New to ruby questions

From: Jeremy W.

end
but, this code doesn’t work. I was thinking it would work similar to
this. If you or anyone else has any ideas please let me know. thanks.

To start you off:

def points
case @value
when ‘2’…‘9’
@value.to_i
when ‘ace’
11
else
10
end
end

I think you’ll have trouble with the ace, though:
In order to determine the value of the ace, you need to know the value
of the whole hand.
In order to determine the value of the whole hand, you need to know the
value of the ace.
In order to determine the value of the ace, …

With the ace all you have to do is check to see if the total hand
values is going to be > 21 with the ace as 11 if so the ace will
become 1. The issue is when the ace is in the hand and you hit again.
It’s value could change.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs