• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

switch does nothing

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi people. I have also posted this in I/O and Streams topic as not sure where this belongs. I have a few problems at the moment. Below is my incomplete program. It compiles but doesn't do a whole lot when run. I am doing a project on polymophism and inheritance. I have a footwear class(parent) and sneaker & thong classes(children)...my switch statements don't do anything. I'm trying to setColour to "something"(eg: whatever option user chooses), then it is written to a file. What's going on?
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For cases 1 2 and 3 you have a non terminating loop!

do
{
switch(choice)
{
case 1: setColour("Red") ; break ;
case 2: setColour("Blue") ; break ;
case 3: setColour("White") ; break ;
default: System.out.println("Enter number 1, 2, or 3:") ;
}
}while(choice != 1 || choice != 2 || choice != 3) ;
 
Ma Chan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks, have fixed it
 
Ranch Hand
Posts: 1067
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

you have a non terminating loop!


Those are the best, I love those guys.
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only if the loop contents include:
(Employee)Cindy.giveRaise(now);
Yep - that can keep looping forever!
 
reply
    Bookmark Topic Watch Topic
  • New Topic