Results 1 to 8 of 8
  1. #1
    big
    big is offline Member
    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Default Console Interface Grid

    Hello I was wondering if anyone knows how to make grid 10*10 within a console interface without using arrays.

    It should look like this (dots should are more spread out when outputted):

    9 . . . . . . . . . .
    8 . . . . . . . . . .
    7 . . . . . . . . . .
    6 . . . . . . . . . .
    5 . . . . . . . . . .
    4 . . . . . . . . . .
    3 . . . . . . . . . .
    2 . . . . . . . . . .
    1 . . . . . . . . . .
    0 . . . . . . . . . .
    0 1 2 3 4 5 6 7 8 9

    The program I need to make is similar to battleship, however it is different. The aim is to select a coordinate (e.g. 5,5) and try and hit the coordinate in which the monster is hiding behind. The monster is hiding randomly behind one of the coordinates.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    What is wrong with plan ol' print statements? If you are looking for more control over the spacing then use the printf method. If this doesn't help then provide further details of what your problem is.

  3. #3
    big
    big is offline Member
    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Default

    I want to be able to relate coordinates to the grid? I am still able to do that by just using printing statements?

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Well you could do it without using arrays but I think it will be much easier using a 2D array.

  6. #6
    big
    big is offline Member
    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Default

    Because part 1 of the assignment is not using arrays, only part 2 is in which is used to do something else. I am just stuck on making the grid.

    I know how to make grid with for loops:
    public void size(){
    for (int x = 1; x <= ROWS; x++){
    for(int y = 1; y <= COLS; y++){
    System.out.print(" . ");
    }
    System.out.print("\n");
    }
    }

    I just don't if that is the right way or could I use "gridLayout"?
    And how I could somehow slot the random position of monster in there.

  7. #7
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default

    Does part 1 of the assingment say "DO NOT USE ARRAYS"? If not use them.

  8. #8
    big
    big is offline Member
    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Default

    It doesn't say that BUT we haven't learnt about two dimensional arrays, so I can't use them :S.

Similar Threads

  1. Grid Painting?
    By iCon09 in forum New To Java
    Replies: 2
    Last Post: 02-26-2011, 08:04 AM
  2. How can I square(^2) the pic in the grid
    By racewithferrari in forum New To Java
    Replies: 2
    Last Post: 11-03-2009, 06:27 PM
  3. How can I square(^2) the pic in the grid
    By racewithferrari in forum New To Java
    Replies: 1
    Last Post: 11-01-2009, 11:16 PM
  4. how to get the grid values
    By jazz2k8 in forum Advanced Java
    Replies: 2
    Last Post: 11-06-2008, 03:11 PM
  5. Help with Grid Layout
    By coco in forum AWT / Swing
    Replies: 1
    Last Post: 08-06-2007, 09:03 PM

Tags for this Thread

Posting Permissions

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