import java.awt.*; import java.awt.geom.*; public class Die2 { public int value; public Die2() { value = 0; } public void rollValue(int maxValue) { double tempValue = Math.random() * maxValue; value = (int) Math.floor( tempValue ) + 1; } public void drawDie(Graphics2D screen2D, float x, float y, Color dieCol) { if (dieCol == null) screen2D.setColor(Color.red); else screen2D.setColor(dieCol); RoundRectangle2D.Float d1 = new RoundRectangle2D.Float(x, y, 100F, 100F, 20F, 20F); screen2D.fill(d1); screen2D.setColor(Color.black); RoundRectangle2D.Float o1 = new RoundRectangle2D.Float(x, y, 100F, 100F, 20F, 20F); screen2D.draw(o1); screen2D.setColor(Color.white); if (value > 1) { Ellipse2D.Float s1 = new Ellipse2D.Float(x+5, y+5, 20F, 20F); screen2D.fill(s1); Ellipse2D.Float s2 = new Ellipse2D.Float(x+75, y+75, 20F, 20F); screen2D.fill(s2); } if (value > 3) { Ellipse2D.Float s1 = new Ellipse2D.Float(x+75, y+5, 20F, 20F); screen2D.fill(s1); Ellipse2D.Float s2 = new Ellipse2D.Float(x+5, y+75, 20F, 20F); screen2D.fill(s2); } if (value == 6) { Ellipse2D.Float s1 = new Ellipse2D.Float(x+5, y+40, 20F, 20F); screen2D.fill(s1); Ellipse2D.Float s2 = new Ellipse2D.Float(x+75, y+40, 20F, 20F); screen2D.fill(s2); } if (value % 2 == 1) { Ellipse2D.Float s1 = new Ellipse2D.Float(x+40, y+40, 20F, 20F); screen2D.fill(s1); } } }