Question: What is the difference between coding 10 rocks to a world and then creating a method to add 10 leaves to the world. Going off

What is the difference between coding 10 rocks to a world and then creating a method to add 10 leaves to the world. Going off of that how would I change it to where when the code is reset there location is random each time?

I have my rocks coded so far as

Rock rock = new Rock();

addObject(rock, 3, 6);

Rock rock2 = new Rock();

addObject(rock2, 1, 1);

Rock rock3 = new Rock();

addObject(rock3, 9, 2);

Rock rock4 = new Rock();

addObject(rock4, 8, 8);

Rock rock5 = new Rock();

addObject(rock5, 4, 2);

Rock rock6 = new Rock();

addObject(rock6, 8, 0);

Rock rock7 = new Rock();

addObject(rock7, 0, 7);

Rock rock8 = new Rock();

addObject(rock8, 2, 3);

Rock rock9 = new Rock();

addObject(rock9, 6, 6);

Rock rock10 = new Rock();

addObject(rock10, 7, 2);

but Im being told to add the leafs differently i've been trying

Leaf leaf = new Leaf();

addLeaf(10);

but I keep getting error in my code.

I'm stuck and any help would be great.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!