
import java.awt.*;
/**
 * DiceDisplay is the display class for drawing a dice of a specified
 * size in a specified location. This class can be used in any graphics
 * program.
 */
public class DiceDisplay 
{   //Pip locations and size constants (relative to a dice size of 1)
   private final double PIP_RADIUS = 0.1;
   private final double PIP_OFFSET = 0.8*PIP_RADIUS;
   //Position of center pip
   private final double CENTER_PIP_X = 0.5 - PIP_RADIUS;
   private final double CENTER_PIP_Y = 0.5 - PIP_RADIUS;
   //Positions of diagonal pips




   //Positions of backdiagonal pips
   
  
 

   //Positions of side pips




   
   //Constants for colors
   private final Color DEFAULT_DICE_COLOR = Color.white;
   private final Color DEFAULT_PIP_COLOR = Color.black;
   
   //Fields
   private int mySize;  //Size in pixels of the dice
   private int myX; //X coordinate of upper left dice corner
   private int myY; //Y coordinate of the upper left dice corner
   private Color myColor;
   
   //Constructor
   public DiceDisplay(int diceSize, int diceX, int diceY)
   {
      mySize = diceSize;
      myX = diceX;
      myY = diceY;
   }
   
   //Method that actually draws the dice to show a certain value
   public void drawDice(Graphics graphicsContext, int diceValue) {
      // Create a temporary graphics context to be polite
      Graphics graphicsDice = graphicsContext.create();
 
      graphicsDice.drawRect(myX, myY, mySize, mySize);
              //<== Add a select statement to draw pips based on diceValue
	graphicsContext.setColor(myColor);
	switch(diceValue) {
		case 1:
      drawCenterPip(graphicsDice);
	  break;
		case 2:
	  drawSidePips(graphicsDice);
	  break;
		case 3:
	  drawDiagonalPips(graphicsDice);
      drawCenterPip(graphicsDice);
	  break;
		case 4:
	  drawBackDiagonalPips(graphicsDice);
	  drawDiagonalPips(graphicsDice);
	  break;
		case 5:
	  drawDiagonalPips(graphicsDice);
	  drawBackDiagonalPips(graphicsDice);
      drawCenterPip(graphicsDice);
	  break;
		case 6:
	  drawDiagonalPips(graphicsDice);
	  drawBackDiagonalPips(graphicsDice);
	  drawSidePips(graphicsDice);
	  break;
		default:
	  break;
	}
	graphicsContext.setColor(DEFAULT_PIP_COLOR);
   }

   //Add accessors as needed
   void setPipColor(Graphics g, Color color)
   {
		myColor = color;
   }

	void setSize(int size)
	{
		mySize = size;
	}

	void setPosition(int x, int y)
	{
		myX = x;
		myY = y;
	}
   
   // Private helper functions
   private void drawCenterPip(Graphics g) 
   {
      drawPip(g, CENTER_PIP_X, CENTER_PIP_Y);
   }
   
   private void drawDiagonalPips(Graphics g)
   {
		drawPip(g, PIP_OFFSET, PIP_OFFSET);
		drawPip(g, 
			1 - (PIP_OFFSET + (2 * PIP_RADIUS)), 
			1 - (PIP_OFFSET + (2 * PIP_RADIUS)));
   }
   
   private void drawBackDiagonalPips(Graphics g)
   {
		drawPip(g, 
			PIP_OFFSET,
			1 - (PIP_OFFSET + (2 * PIP_RADIUS)));
		drawPip(g, 
			1 - (PIP_OFFSET + (2 * PIP_RADIUS)),
			PIP_OFFSET);
		
   }
   
   private void drawSidePips(Graphics g)
   {
	drawPip(g,
			PIP_OFFSET,
			CENTER_PIP_X);
	drawPip(g,
			1 - (PIP_OFFSET + 2 * PIP_RADIUS),
			CENTER_PIP_X);
   }
   
  // Draws a pip at the specified location (xCorner, yCorner)
  // which is expressed in terms of a 1x1 die located at (0,0)
  // The drawPip method automatically multiplies by the scale
  // and translates by the die position (myX, myY) 
   private void drawPip(Graphics g, double xCorner, double yCorner) 
   {
      int x = (int)(myX + xCorner * mySize);
      int y = (int)(myY + yCorner * mySize);
      int size = (int)(2.0*PIP_RADIUS * mySize);
      g.fillOval(x, y, size, size);
   }
}

