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

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

 
Greenhorn
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
 
Marshal
Posts: 76884
366
  • 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
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic