• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Bumper car errors

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been working on this program for a while now, and I can't seem to get it to work right.

Classes here

My problem is that I cannot get the cars to stay inside the "grid" no matter what I do. I've tried different methods to do it, the one I have now works "in theory" but I cannot produce the results on screen that I do when I run through the numbers in my head.

If someone could run through it and see if there is a logic error in there or if "in theory" just won't do it with this particular set-up, that would help a bunch.

Right now, I need some guidance becuase it's got me stumped. Thanks in advance guys!
[ December 05, 2004: Message edited by: Jeremy Anderson ]
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just had a quick look at your code there so this may not be the problem. You display a grid of between 0,10 by 0,10 as far as I can see but you're checking for co-ordinates in a grid of size -10,10 by -10,10 I'm guessing this is where you're problems lie if you change you hitWall function appropriately you might be a bit further on.
Give a shout back and let us know how you get on!
Barry
 
Jeremy Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will try to give that a go, although I don't think that's the problem. The grid runs from -10/10 and -10/10, and the move method will subtract from the current coordinates as necessary (moving south). Thanks for the help so far, I will let you know how it goes.
 
Barry Higgins
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeremy,
I've updated your class slightly and it now appears to work. I took out the grid building and input stuff as I don't have Java 1.5 installed, so I was just looking at the cordinates and none of them went over (or under) the limits.



Note I also implemented an interface to keep an eye on your constants you should be able to see what was in it from what won't compile here!
Anyway post with any issues,
Barry
 
Jeremy Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, I appreciate you taking time out of your day to help me. The only question I have is about the constants, since that was not included. I'm assuming that NORTH =1, NORTH_EAST=2, etc, etc, and that MAX_X and MAX_Y are both = 10. If that's the case, I can create the super class and let er rip. Thanks again!
 
Jeremy Anderson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it working, thanks very much. Keep your helping hand warm, got another project started!
 
The knights of nee want a shrubbery. And a tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!