How to compare card values or even store them ?
I'm pulling data from an API that gives me 1 card - and then I want to compare their values to see which one is higher with the next card.. how can I do something like that ?
My values are pulled from an API and they return 'K' for King, or '5' for 5, 'A' for Ace and so on.. but I'm not sure how could I compare values of different types together ?
CodePudding user response:
Create a Card
-class and make it either Comparable
more write a Comparator<Card>
CodePudding user response:
You can use a dictonary.
var cards = {
'A' = 14, // Ace
'K' = 13 // King
}
Or you can use an enum like object:
const Cards = {
A: 14, // Ace
K: 13 // King
};