I have been learning C++ for a few weeks and I am now trying to program a little thing by myself and practice what I learned at the same time.
So my program is a poker hand distributor.
I started by creating a simple "card" class which contains two methods, value and suit.
At first I tried to do an enum for both, but I couldn't set the enum with integers (for exampleenum value {2,3,4,5,6,7,8,9,T,J,Q,K,A}
doesn't work, which is normal.
My enum for suits works just fine, it's just that when I want to print a card (i implemented operator<<
in my class) I don't know how to convert my integers to the corresponding suits. I will get for example 10 1 for ten of spades. I would like to know how to convert this in my operator<<()
function to get something like T s
when I want to print a card using cout << card
which contains the informations 10 and 1
;
;
tldr I want to know how to convert for example "10 1" to "T s (T spades)" while keeping 2 to 9 as such (9 1->9 s)
Thank you!!