作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
学校给我布置了一个骰子游戏,用户可以改变骰子的眼睛,他们给我的唯一提示是使用 ASCII 表。
这是我到目前为止的代码,我正在碰壁,因为我如何使数字成为用户的输入(我不是很有创意):
System.out.println("Which character should be used as the eye of the dice:");
char eyeDice = input.next().charAt(0);
System.out.println(eyeDice);
int Dice;
Dice = (int)(Math.random()* 6 + 1);
while (Dice < 6) {
Dice = (int)(Math.random()* 6 + 1);
System.out.println(Dice);
}
代码的输出如下所示:
Which character should be used as the eye of the dice:
$
$
1
4
1
1
1
1
4
1
2
2
6
Process finished with exit code 0
这就是它最终的样子:
Which character should be used as the eye of the dice:
#
#
#
# #
#
# #
# #
# #
# #
# #
Process finished with exit code 0
任何正确方向的提示或提示将不胜感激!
最佳答案
计算机没有附带将数字“4”转换为 ascii 绘图的代码。
你必须自己写这个。我建议把这些画在一张纸上。在您的 java 代码中,您可以有一堆 if/elseif 语句,每个语句对应 6 个面。每个 block 将打印 3 行。首先锁定用于眼睛的角色,然后努力使其成为用户稍后可以配置的内容。
以下是帮助您入门的部分内容:
if (dieRoll == 5) {
System.out.println("* *");
System.out.println(" * ");
System.out.println("* *");
} else if (dieRoll == 6) {
// you figure it out from here...
关于java - 改变骰子的眼睛,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52407307/
我对机器学习有一点了解,想自己实现一个学习系统,但不知道该怎么做。谁能给我一个演示或使用其他方法来比较人脸? 这是一个相关的帖子:https://stackoverflow.com/questions
这不是问题,但我很困惑什么 3D 空间对应什么。我习惯于听到模型、 View 、投影空间,但在我的工作中他们使用世界、眼睛、投影。我没有意识到 World 和 Eye 是模型和 View 的同义词,所
我是一名优秀的程序员,十分优秀!