• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

wanted help in the practice program--"Cycling"

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I made this code as a practice exercise......this program should be controlled with simply four
cursor control keys and each key must be assigned a method.....i.e., by pressing a particular
key some operation must be performed....what this program do is it should just reflects the changes in the distance traveled and speed of cycle by accelerating and decelerating the cycle and it should also change direction of the cycle(of course imaginary one since i haven't reached to the topics using graphics) .........as stated below

right cursor key(-->) : turnLeft().....and should change the direction as per the code
left cursor key(<--) : turnRight()....and should change the direction as per the code
up cursor key(<) : paddleMoving(int i)....here 'i' states for number of paddle rounds user
wants to apply which would be asked in the starting of the program
down cusor key : applyBrakes()......which eventually stops the cycle.

but the problem is that i dont know how to use Scanner for cursor keys...therefore i have left the class containing main() method.....Please help

>
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you planning to run the program? Swing or console? If console using Scanner to get inputs of what arrow keys are pressed? If Swing hence graphics ... KeyEvent will suit your needs.
 
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic