this post was submitted on 18 Aug 2023
597 points (96.1% liked)

Programmer Humor

19544 readers
458 users here now

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

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] obosob@feddit.uk 9 points 1 year ago* (last edited 1 year ago) (2 children)

Yeah, just use a char for card and test

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

Or something, don't mix types.

[–] Hexarei@programming.dev 1 points 1 year ago (1 children)

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

[–] obosob@feddit.uk 2 points 1 year ago

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

[–] nothacking@discuss.tchncs.de 1 points 1 year ago (1 children)

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

[–] obosob@feddit.uk 2 points 1 year ago

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