I’ve failed at several projects, I’ve hit my limits many times, and I’ve been fired from jobs. None of those things caused me to quit programming. Short version: never give up (but know when to cut your losses on a project).
Java is a pretty complicated ecosystem…have you thought about trying to apply your card-counting logic in a simpler language? Or even pseudocode? If you want tips on how to accomplish that goal, many of use here would likely be willing to help. There’s no shame on giving up a project when you’ve bitten off more than you can chew…please do not give up on programming in general though.