This site requires JavaScript, please enable it in your browser!
Greenfoot back
WardedBowl403
WardedBowl403 wrote ...

2017/12/16

Integer not returning

WardedBowl403 WardedBowl403

2017/12/16

#
I have the return code written, but nothing is being returned. At the top of the class I have the variable "d1" set to a value of 1. This is what I have written to return.
public void act()
{
      it();
}

public int it()
{
      return d1;
}
Super_Hippo Super_Hippo

2017/12/16

#
So... line 3 calls the method and it returns d1. So line 3 is essentially 'd1;' or '1;' What is supposed to happen?
WardedBowl403 WardedBowl403

2017/12/17

#
Super_Hippo wrote...
So... line 3 calls the method and it returns d1. So line 3 is essentially 'd1;' or '1;' What is supposed to happen?
Normally, it will create a popup window that has a box with the returned value. However, that is not happening.
Super_Hippo Super_Hippo

2017/12/17

#
As far as I know, that only happens when you right click the object and choose the method. I am happy that not every method call creates a pop up window to be honest.
WardedBowl403 WardedBowl403

2017/12/17

#
Super_Hippo wrote...
As far as I know, that only happens when you right click the object and choose the method. I am happy that not every method call creates a pop up window to be honest.
Hmm okay. The computers at my school always create a popup when a function with a return type that isnt void is called. I guess those computers are also running and older version of greenfoot. Thanks for the help, I was very confused.
You need to login to post a reply.