如何在卡片甲板中设置卡片的值,并比较哪个具有“更高”的值或“下部”价值?

发布于 2025-02-07 23:00:10 字数 136 浏览 2 评论 0原文

如何比较卡值甚至存储它们?

我正在从一个给我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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

双马尾 2025-02-14 23:00:10

您可以使用词典。

var cards = {
 'A' = 14, // Ace
 'K' = 13  // King
}

或者,您可以使用像对象这样的枚举:

const Cards = {
  A: 14, // Ace
  K: 13  // King
};
   

You can use a dictionary.

var cards = {
 'A' = 14, // Ace
 'K' = 13  // King
}

Or you can use an enum like object:

const Cards = {
  A: 14, // Ace
  K: 13  // King
};
   
红墙和绿瓦 2025-02-14 23:00:10

创建card -class,然后使其成为可比更多编写比较器< card>

Create a Card-class and make it either Comparable more write a Comparator<Card>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文