Skip to Main Content

New to Java

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!

Help With Simple Java Canvas Relay Race

843785Oct 3 2008 — edited Oct 6 2008
So I've been given an assignment to make this relay race type thing, which I did, but not the way I was supposed to apparently.
Basically I need to construct 4 square objects, position them in each corner of the canvas and have them participate in a relay race, one moving once it has been touched by the last.
I managed that by doing this.
     public static void relayRace()
    {
      
       Square nw = new Square(0, 0, "blue", 10);
       Square ne = new Square(290,0, "yellow", 10);
       Square se = new Square (290,290,"red", 10);
       Square sw = new Square (0,290,"magenta",10);
       
        nw.slowMoveHorizontal(280);
        ne.slowMoveVertical(280);
        se.slowMoveHorizontal(-280);
        sw.slowMoveVertical(-290);
   
    } 
note. SlowMove methods just slowly move the object horizontally or vertically.

The problem with this code, is that I was instructed to use a method header like this...
  public void relay(Square nw, Square ne, Square se, Square sw)
   {
        nw.slowMoveHorizontal(280);
        ne.slowMoveVertical(280);
        se.slowMoveHorizontal(-280);
        sw.slowMoveVertical(-290);
    }
and when I void the second method it asks me to pass parameters to each square object before it will run, which I don't know how to do?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 3 2008
Added on Oct 3 2008
9 comments
424 views