• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Can someone tell me why?

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Can someone tell me why--after i create a cube--it display 'enter test operation' twice?



[ November 17, 2008: Message edited by: Bear Bibeault ]
 
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
marcus conway
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

Lastly, in the future UseAMeaningfulSubjectLine that states what the problem is.

[ 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
Rancher
Posts: 43026
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?



how bout this?
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think Ulf was hinting you should read about the break keyword in a switch statement
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
FAQ: Use A Meaningful Subject Line

welcome,

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 ]
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic