2.3 KiB
2.3 KiB
Hints
General
- Conditionals are used to check for certain conditions and/or criteria. The most basic way of performing a conditional operation is using a single
if
statement.
1. Calculate the score of any given card.
- The
ParseCard
function should take thecard
string (e.g.ace
) and turn it into its value (e.g. 11). - Use a big
switch
statement on thecard
variable. - King, Queen, Jack and 10 can be handled with a single case.
- The switch can have a
default
case. In any case the function should return0
for unknown cards.
2. Determine if two cards make up a Blackjack.
IsBlackJack
checks if 2 cards have the combined value of 21.- Should use the
ParseCard
function to get the value for each card. - Should sum up the values of the 2 cards.
- Should return
true
if the sum is equal to21
. - No
if
statement is needed here. The result for the comparison can be returned.
3. Implement the decision logic for hand scores larger than 20 points.
- As the
LargeHand
function is only called for hands with a value larger than 20, there are only 2 different possible hands: A BlackJack with a total value of21
and 2 Aces with a total value of22
. - The function should check if
isBlackJack
istrue
and return "P" otherwise. - If
isBlackJack
istrue
, the dealerScore needs to be checked for being lower than 10. If it is lower, return "W" otherwise "S".
4. Implement the decision logic for hand scores with less than 21 points.
- The
SmallHand
function is only called if there are no Aces on the hand (handScore
is less than 21). - Implement every condition using logical operators if necessary.
- If your cards sum up to 17 or higher you should always stand.
- If your cards sum up to 11 or lower you should always hit.
- If your cards sum up to a value within the range [12, 16] you should always stand if the dealer has a 6 or lower.
- If your cards sum up to a value within the range [12, 16] you should always hit if the dealer has a 7 or higher.