You are viewing a single thread.
View all comments View context
9 points
*

Yeah, just use a char for card and test

if(card < '7') count++;
else count--;

Or something, don’t mix types.

permalink
report
parent
reply
1 point

The cards should just be numbers, and an enum should be used for display names

permalink
report
parent
reply
2 points

Chars are just numbers, but yeah, an enum would work fine too, sure. The only advantage with using a char for it is that there’s no conversion needed for outputting them into strings so it’s a little easier. Less code, very readable, etc. Though yeah, thinking about it JQKA wouldn’t be numerically in the right order which could cause issues if the program did more than just implement HiLo

permalink
report
parent
reply
1 point

Well that won’t work for 7, 8 or 9.

permalink
report
parent
reply
2 points

I didn’t notice that 7,8,9 had no effect on the count. My bad.

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 7.6K

    Monthly active users

  • 978

    Posts

  • 38K

    Comments