Card game switching Q K J and T from string to numbers and adding the card up

조회 수: 2 (최근 30일)
dotty daniels
dotty daniels 2021년 2월 16일
편집: dpb 2021년 2월 17일
Ok so my input comes in with an answer of face value of two card. ie... 'Q2' is a queen and a two... I need to add the cards together but I need to fist change all Q K J T to Q,K,J,T=10 and A=11 then add them.... How would I arrange my if else... I've been playing with string2num and letters2num and I can't seem to get it.
  댓글 수: 2
dpb
dpb 2021년 2월 16일
편집: dpb 2021년 2월 17일
>> FACES='JQKA'
FACES =
'JQKA'
>> card='Q';
>> V=strfind(FACES,card)+9
V =
11
>> card='A';
>> V=strfind(FACES,card)+9
V =
13
>>
David Hill
David Hill 2021년 2월 17일
Depending on what you are doing, you might want to look at defining card as a class.
classdef card

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Card games에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by