Black jack function for hiding dealers card
2 views (last 30 days)
Show older comments
I have the game pretty much completed. its a text based version of blackjack just focusing on random integers since suits dont really matter.
I need a function to store the hole card, display an empty string (ex: __ / 9 / 2) and then display the value once the player "stays".
Thank you!
0 Comments
Accepted Answer
Voss
on 1 Dec 2021
I'll assume the dealer's cards are stored as an array with the hole card being first. Then here's a function that takes two input arguments: (1) dealer's card array, (2) a logical indicating whether to hide the hole card, and returns a character array representing the cards:
function str = get_str(d,do_hide)
d = num2cell(d);
str = sprintf('%2d / ',d{:});
str(end-2:end) = [];
if do_hide
str([1 2]) = '_';
end
end
More Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!