Results 1 to 2 of 2

Thread: while loop help

  1. #1
    kathyla18 is offline Member
    Join Date
    Feb 2009
    Rep Power

    Default while loop help

    hi , i created the game battleship but im supposed to end it after the 17th hit 5 hits for ship A 4 for ship B 3 for ship P 3 for ship D and 2 for ship S. What i did was to create a while loop
    while i< 17
    //my board is here
    if (gameBoard.guessPosition(row, column)== true) {

    but i realized that if i do that then if the user hits the same ship 17 times the game ends too. I dont know how to make it end after all of the ships have been hit. Any help will be appreciated. Thanks

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Rep Power


    An array of booleans set to true when that ship part has been hit, and a counter to keep track of how many times a value actually changes.

Similar Threads

  1. Help w/ loop
    By iWonder in forum New To Java
    Replies: 17
    Last Post: 11-20-2008, 12:39 AM
  2. While loop
    By sjhentges in forum New To Java
    Replies: 11
    Last Post: 11-04-2008, 04:26 PM
  3. Need help with While Loop
    By mrdestroy in forum New To Java
    Replies: 14
    Last Post: 10-20-2008, 02:29 PM
  4. do...while loop
    By eva in forum New To Java
    Replies: 16
    Last Post: 01-31-2008, 06:44 AM
  5. can you help me with this for loop?
    By java_fun2007 in forum New To Java
    Replies: 6
    Last Post: 12-22-2007, 10:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts