Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Dice Class Method

807591Mar 25 2008 — edited Mar 26 2008
Hello all, new here.

I've been constructing a program with a set of instances simulating a playing dice but I'm kind of stuck. Beginner and all that.
public class Dice
{
   /* instance variables */
   private Square sq; 
   private Circle topLeft;
   private Circle bottomLeft;
   private Circle middle;
   private Circle topRight;
   private Circle bottomRight;
   private Random ran = new Random();


   /**
    * Constructor for objects of class Dice
    */
   public Dice(Square s, Circle tL, Circle bL, Circle mid, Circle tR, Circle bR)
   {
      super();
      this.sq = s;
      this.topLeft = tL;
      this.bottomLeft = bL;
      this.middle = mid;
      this.topRight = tR;
      this.bottomRight = bR;
      this.sq.setLength(75);
   }
      

   /* instance methods */
  public void initialiseSpots() 
   {

   /**
    * Sets the side of the receiver to 0 spots
    */   
   public void side0()
   {
      this.topLeft.setColour(OUColour.ORANGE);
      this.topRight.setColour(OUColour.ORANGE);
      this.middle.setColour(OUColour.ORANGE);
      this.bottomLeft.setColour(OUColour.ORANGE);     
      this.bottomRight.setColour(OUColour.ORANGE);
   }
   
   
   /**
    * Changes the side of the receiver to either 0, 1, 3, 3, 4 or 5
    * spots depending on the value of the argument.
    */
}
All the circles that are referenced by the instance variables topLeft, bottomLeft,
middle, topRight and bottomRight have their xPos and yPos set to the default of 0.

I need to set in the method the xPos and yPos of each of these circles so that they are distributed over the square like a the circles similar to how a dice looks when it's got 5 dots.

Any help would be much appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 23 2008
Added on Mar 25 2008
21 comments
324 views