Can someone tell me why--after i create a cube--it display 'enter test operation' twice?
[ November 17, 2008: Message edited by: Bear Bibeault ]
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
That's in a loop, so I'd assume that the loop is executed repeatedly. Check whether the loop termination condition works as you expect it to.
By the way, I'm almost positive that the getValue method does not work as you expect it to work. You may want to read about the "switch" statement, and what happens once one of the cases is matched.
Lastly, in the future UseAMeaningfulSubjectLine that states what the problem is. [ November 17, 2008: Message edited by: Ulf Dittmer ]
Originally posted by Ulf Dittmer: That's in a loop, so I'd assume that the loop is executed repeatedly. Check whether the loop termination condition works as you expect it to.
By the way, I'm almost positive that the getValue method does not work as you expect it to work. You may want to read about the "switch" statement, and what happens once one of the cases is matched.
[ November 17, 2008: Message edited by: Ulf Dittmer ]
Is it because I'm using the getValue() switch statement on chars?
Thanks for your help
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
No, chars work fine in switch statements. Ask yourself this: Suppose getFace() returns 't', causing "val = 1;" to be executed. Now, what is the next statement that gets executed? And consequently, which value of "val" will be returned from the method?
marcus conway
Greenhorn
Joined: Oct 30, 2008
Posts: 12
posted
0
Originally posted by Ulf Dittmer: No, chars work fine in switch statements. Ask yourself this: Suppose getFace() returns 't', causing "val = 1;" to be executed. Now, what is the next statement that gets executed? And consequently, which value of "val" will be returned from the method?
history note: the good ol' switch statement comes down to us from the C programming language, the first step up from assembly programming, and as such still requires a little bit more work to do what you want it to,
(i.e. check on the break keyword as suggested above - and/or trace through the debugger and see how it's executing) [ November 17, 2008: Message edited by: Bill Shirley ]
Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);