Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Minor problem which im pulling my hair out over

 
Mark Shrauve
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all.

Im having difficulty with two programs im trying to run. For the first one here is the basic scheme:

A user inputs a value to adjust a knob to an acceptable value between 0 and 100. So lets say the user inputs 7, the program is to display a message saying the current value is 7 right right after it asks for the user input. Then it asks again for another knob change BUT if the user enter like -300 or 200 (anything higher then 100 or below 0) ONLY a warning message is to pop up AND the value must not be changed (THIS IS the part which kills me). How do I make it so when a bad value comes up the the original good value is kept (the 27 for example) and is kept again if the user inputs a bad value (when it displays the current value again). Here is my code so far.
My Test Class:

My function class

What I'm supposed to be getting

 
Kenneth Albertson
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark. Have a think about this pseudocode. If it does what you require, have a go at writing it in Java.
 
Mark Shrauve
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright cool! Got it, and all I was missing was one dumb else statement with proper coding. One thing that still now I need to check up on is why I keep on getting 0.0 for a reading when my getPosition method is called from the test class.
[ October 10, 2005: Message edited by: Mark Shrauve ]
[ October 10, 2005: Message edited by: Mark Shrauve ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic