如何在卡片甲板中设置卡片的值,并比较哪个具有“更高”的值或“下部”价值?
如何比较卡值甚至存储它们?
我正在从一个给我1张卡的API中提取数据 - 然后我想比较他们的值,以查看下一张卡更高的数据。.我该怎么做?
我的价值是从API中提取的,它们为King返回“ K”,或者为5,5,a for Ace等。
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用词典。
或者,您可以使用像对象这样的枚举:
You can use a dictionary.
Or you can use an enum like object:
创建
card
-class,然后使其成为可比
更多编写比较器< card>
Create a
Card
-class and make it eitherComparable
more write aComparator<Card>