Go to Post You are joining the greatest family in the world, FIRST, because we all strive to practice GP. - Ken Loyd [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 02-22-2012, 03:18 PM
Brian Selle's Avatar
Brian Selle Brian Selle is offline
Mentor
FRC #3310 (Black Hawk Robotics)
Team Role: Engineer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Texas
Posts: 162
Brian Selle has a spectacular aura aboutBrian Selle has a spectacular aura aboutBrian Selle has a spectacular aura about
Re: Robots can't count: Microswitches

If your pseudo code matches your real code, the module level variable totalBalls defined at:

Quote:
Originally Posted by NS_Radication View Post
Int totalBalls = 2
Will never be updated because the variable totalBalls defined as a argument to your method will take precedence.

Quote:
Originally Posted by NS_Radication View Post
public int microSwitch(int totalBalls)

Try renaming the module level variable to m_totalBalls or another name. Also, you only need to check the upper limit when adding:

If (addball.get() = true and totalBalls < 3
Then totalBalls += 1

And the lower limit when subtracting:

If (minusball.get() = true and totalBalls > 0
Then totalBalls -= 1
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:41 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi