• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Exception catching

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The bold is where I am having trouble (beginning at line 19 ending at 36). At first, I was trying to make my boolean I yes or no instead of true or false. When I couldn't figure that out I decided to do a try-catch to prompt the user to enter true or false.
Two things happened. 1st the "inService" variable in line 36 now says it couldn't be resolved. So I used the eclipse suggestion and created a field for 'inService'. When I ran the program and got to t that part the loop never stopped, I had to terminate the console manually.

I'm going to have to implement a try-catch for the rooms also to make sure the user doesn't input a string such as "three" instead of "3". I was going to use this same method but I can't get this one working.

Any help or advice would be greatly appreciated.
 
Marshal
Posts: 15630
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The user can type in either "yes" or "no" and you can turn that into a boolean by checking if it is equals() to "yes" or "no":
 
We begin by testing your absorbancy by exposing you to this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic