• 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

how to execute a previous step after scanning an error value?

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
]Hello, so i have this game iam working on for homework, which is basically the Battleship game written in java, still in the beginning and stuck at this step :

what i want is after i enter a Wrong value which is <0 or >10 the program would go back to the System.out.println("Enter the row of the ship"); step so i can retype a correct value !
sorry if my question is hard to understand iam still a newbie in java (first semester in uni)
Thanks for the help

i still cant get how to put the code so there would be line numbers next to each line, sorry
Posts: 76884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Thank you for finding the code button, but you didn't quite use it correctly. Look here for how it works. I have corrected it for you and doesn't it look better

You can put the call to enter the number inside a loopBut that sort of code doesn't belong there. It belongs in a different method. Probably in a different class. When you try to enter the column or the orientation, you will see you are writing the same sort of code again.
eat bricks! HA! And here's another one! And a tiny ad!
the value of filler advertising in 2021
    Bookmark Topic Watch Topic
  • New Topic