Red Dice 我一直在上课的掷骰子游戏,我无法完成代码,因为我不知道如何在模具上绘制实际的点。我有桌子和实际的模具,而不是骰子上的点。我需要帮助来绘制它们。骰子是红色的。这就是我所拥有的:
// Draws a given number of dots on this die
private void drawDots(Graphics g, int x, int y, int numDots)
{
g.setColor(Color.WHITE);
int dotSize = dieSize / 4;
int step = dieSize / 8;
int x1 = x + step - 1;
int x2 = x + 3*step;
int x3 = x + 5*step + 1;
int y1 = y + step - 1;
int y2 = y + 3*step;
int y3 = y + 5*step + 1;
switch (numDots)
{
case 1:
g.fillOval(x2, y2, dotSize, dotSize);
break;
case 2:
g.fillOval(x3, y1, dotSize, dotSize);
g.fillOval(x1, y3, dotSize, dotSize);
break;
case 3:
g.fillOval(x1, y1, dotSize, dotSize);
g.fillOval(x2, y2, dotSize, dotSize);
g.fillOval(x3, y3, dotSize, dotSize);
break;
case 4:
g.fillOval(x1, y1, dotSize, dotSize);
g.fillOval(x3, y3, dotSize, dotSize);
g.fillOval(x1, y3, dotSize, dotSize);
g.fillOval(x3, y3, dotSize, dotSize);
break;
case 5:
g.fillOval(x1, y1, dotSize, dotSize);
g.fillOval(x2, y2, dotSize, dotSize);
g.fillOval(x3, y1, dotSize, dotSize);
g.fillOval(x1, y3, dotSize, dotSize);
g.fillOval(x3, y3, dotSize, dotSize);
break;
case 6:
g.fillOval(x1, y1, dotSize, dotSize);
g.fillOval(x2, y1, dotSize, dotSize);
g.fillOval(x3, y1, dotSize, dotSize);
g.fillOval(x1, y3, dotSize, dotSize);
g.fillOval(x2, y3, dotSize, dotSize);
g.fillOval(x3, y3, dotSize, dotSize);
break;
}
}
}
我不知道我做错了什么。当我运行骰子时,它们不会在它们上面显示任何点。
答案 0 :(得分:0)
修正了我的问题。我的Die.java课并没有说它需要什么。谢谢你的帮助!
原来我的班级说:
Dim R1 As Range
Set R1 = Range(Range("A2:AX2").Find("BMA Authorization ID"), Range("A2:AX2").Find("BMA Authorization ID").End(xlDown))
R1.Select
R1.Copy
R1.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
什么时候应该说:
import java.util.Random;
public class Die
{
private final static Random random = new Random();
public Die()
{
}
public int getRoll()
{
return random.nextInt(6)+1;
}
public int getNumDots()
{
// TODO Auto-generated method stub
return 0;
}
}