• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Return types and methods

 
Alix Ollivier
Ranch Hand
Posts: 71
Java Linux Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each time I want to move my character in the game I am building, I do code like this. and I write goLeft like this:

Is this correct, to call a return and have it call to itself? Or is there a way I can simply call goLeft without the accompanying coordinateX=? Coordinate X and Y are outside of the method.
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't call it incorrect but I think a more elegant approach would be
 
Paul Clapham
Sheriff
Posts: 20990
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would just do this:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic