Results 1 to 5 of 5
  1. #1
    Thumper is offline Member
    Join Date
    Dec 2009
    Posts
    11
    Rep Power
    0

    Default Using an Instance method

    I have my constructor written, but I need to execute an Instance variable called reset() which will call the method reset and place a dot into the middle of a square.

    Here is my constructor


    /**
    * Constructor for objects of class Dice
    */
    public Dice(Square bg, Circle tL, Circle tM, Circle tR, Circle mid, Circle bL, Circle bM, Circle bR)
    {
    background = bg;
    bg.setLength(75);
    tL = topLeftSpot;
    tM = topMiddleSpot;
    tR = topRightSpot;
    mid = middleSpot;
    bL = bottomLeftSpot;
    bM = bottomMiddleSpot;
    bR = bottomRightSpot;
    this.reset();
    }

    here is the instance method

    public void reset()
    {
    this.getBackground().setXPos(0);
    this.getTopLeftSpot().setXPos(3);
    this.getTopLeftSpot().setYPos(3);
    this.getTopMiddleSpot().setXPos(25);
    this.getTopMiddleSpot().setYPos(3);
    this.getTopRightSpot().setXPos(48);
    this.getTopRightSpot().setYPos(3);
    this.getMiddleSpot().setXPos(25);
    this.getMiddleSpot().setYPos(25);
    this.getBottomLeftSpot().setXPos(3);
    this.getBottomLeftSpot().setYPos(48);
    this.getBottomMiddleSpot().setXPos(25);
    this.getBottomMiddleSpot().setYPos(48);
    this.getBottomRightSpot().setXPos(48);
    this.getBottomRightSpot().setYPos(48);
    this.face1();
    }

    I can compile the class with out any errors but when I run it the square appears but the dot does not appear in the center like it should. I just can't get the reset to work. I'm sure its a simple fix but as I'm new to Java everything seems complicated

    Thanks for any help
    Last edited by Thumper; 12-06-2009 at 09:58 PM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,846
    Rep Power
    19

    Default

    I wish you'd gone back to your old thread to say you'd fixed it. It's a little rude not to, you know.

    And use code tags, please.

    On the point of the topic...what does face1() do?

  3. #3
    Thumper is offline Member
    Join Date
    Dec 2009
    Posts
    11
    Rep Power
    0

    Default

    Quote Originally Posted by Tolls View Post
    I wish you'd gone back to your old thread to say you'd fixed it. It's a little rude not to, you know.

    And use code tags, please.

    On the point of the topic...what does face1() do?
    I have that fixed for you but I'm still getting the Illegal expression error with the next piece of code

    face1(); places an Orange square with 1 blue dot in the middle.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,846
    Rep Power
    19

    Default

    OK, well there's nothing in the code you've posted that tells us anything about what's going on, or what could be wrong.

  5. #5
    owlsno1 is offline Member
    Join Date
    Dec 2009
    Posts
    24
    Rep Power
    0

    Default

    i'm still stuck on (i)

    trying to initialise the instance variables with the arguments
    anyone help?

Similar Threads

  1. Accessing instance outside of creation method
    By meringue in forum New To Java
    Replies: 6
    Last Post: 03-22-2009, 01:36 AM
  2. [SOLVED] Non-synchronized instance method of an Object
    By piyu.sha in forum Threads and Synchronization
    Replies: 2
    Last Post: 10-06-2008, 06:35 AM
  3. public instance method
    By steve123 in forum New To Java
    Replies: 5
    Last Post: 06-20-2008, 08:45 PM
  4. Instantiation using an instance factory method
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-29-2008, 12:35 PM
  5. Instantiation using an instance factory method
    By JavaBean in forum Java Tip
    Replies: 0
    Last Post: 09-26-2007, 08:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •