如何随机化? [英] How to randomize?

查看:113
本文介绍了如何随机化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习Java,我们有一个需要展示洗牌的项目。我们正在使用物体作为我们的扑克牌,我们已将这些物品放在堆叠中,我想知道是否有人可以帮助我如何洗牌。这些对象或以随机排列放置?

解决方案

您可以开发的最佳技能之一是能够搜索可以使用的方法和类。请查看出去,看看你是否能找到办法做到这一点。如果没有,再次发布您尝试过的内容,我们会尝试让您朝着正确的方向前进。



其中一个您可以开发的最佳技能是搜索可以使用的方法和类的能力。请查看出去,看看你是否能找到办法做到这一点。如果没有,再次发布您尝试过的内容,我们会尽力让您朝着正确的方向前进。



好​​的,非常感谢。我会尝试并尽快发布我想出的内容,因为到目前为止我仍然没有想出如何制作这些物品(卡片)。



您可以开发的最佳技能之一是搜索可以使用的方法和类的能力。请查看出去,看看你是否能找到办法做到这一点。如果没有,再次发布您尝试过的内容,我们会尽力让您朝着正确的方向前进。



我已经想出如何使用Math.random()包,但有没有办法让生成的数字唯一?例如,我只需要0到51之间的数字。你能告诉我如何只生成一个随机数一次,这样最终看起来我是按照随机顺序重新排列数字0到51吗?


I''m just starting learning Java, and we have a project that needs to demonstrate shuffling playing cards. We''re using objects as our playing cards, and we''ve put these objects in stacks, and I wonder if anyone can help me how to "shuffle" these objects or put them in a random arrangement?

解决方案

One of the best skills you can develop is the ability to search for methods and classes that you can use. So check this out and see if you can figure out a way to do that. If not, post again with what you tried, we''ll try to get you headed in the right direction.


One of the best skills you can develop is the ability to search for methods and classes that you can use. So check this out and see if you can figure out a way to do that. If not, post again with what you tried, we''ll try to get you headed in the right direction.

Okay, thanks very much. I''ll try it and post what I come up with as soon as I can, because as of yet I still haven''t figured out how to make the objects (cards).


One of the best skills you can develop is the ability to search for methods and classes that you can use. So check this out and see if you can figure out a way to do that. If not, post again with what you tried, we''ll try to get you headed in the right direction.

I''ve figured out how to use Math.random() package, but is there a way to make the generated numbers unique? For example, I only need numbers from 0 to 51. Can you tell me how I generate one random number only once so that in the end, it seems like I''m rearranging the numbers 0 to 51 in a random sequence?


这篇关于如何随机化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆