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?