-1

I'm Coding for School in Greenfoot on a plugin with which I can program a rover moving over a field...

I want to add two objects with "addObject" on the same.

Mark mark = new Mark();
Rover rover = new Rover();
      addObject(mark && rover, 0, (int)(Math.random() *getHeight()));

This isn't possible. Is there anyway to get this done? I hope you understood what I meant:)

  • Why are you trying to use the AND logical operator on two objects? That is likely your first problem. – Logan Nov 18 '17 at 18:07

1 Answers1

0

First get the numbers you need and store them as variables:

int markRoverY = (int)(Math.random()*getHeight());

and then add the objects with the same variable

addObject(mark, 0,markRoverY);
addObject(rover, 0,markRoverY);

if you want the combined height of the two objects you will have to store a variable of both heights added and then use that when adding to your world