Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2009
    Posts
    1
    Rep Power
    0

    Default Help with ASCII Drawing--For loops--if/else

    Hello,
    I need help with coding of the following object [Link]:

    [i252.photobucket.com/albums/hh8/eretronics/parking_lot.jpg]

    This is what I've tried so far, I think I have made a lot of boo-boos, needs serious editing...


    // linc_size is a constant that determines the length of the drawing
    int linc_size = 4;

    for (int i = 1; i <= linc_size * linc_size; i++)
    {
    for (int j = 1; j <= (linc_size * 2 * 3 * 4); j++)
    {
    if (j <= j + linc_size * 2)
    System.out.println("");
    else if ((j == 1 + linc_size * 2 + 1) ||
    (j == 1 + linc_size * 2 * 2 + 1 + 1) ||
    (j == 1 + linc_size * 2 * 2 + 1 + 1 + 1))
    System.out.println(" ");
    else if ((j == 1 + linc_size * 2 + 1 + 1) ||
    (j == 1 + linc_size * 2 * 2 + 1 + 1 + 1) ||
    (j == 1 + linc_size * 2 * 2 + 1 + 1 + 1 + 1))
    System.out.println("|");
    else
    System.out.println("_");

    }
    System.out.println();
    }

  2. #2
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    The code above is a mess, use code tags.
    Having said that, here's the pseudo code:
    Java Code:
    printFirstLine();
    LOOP:
      printCell(); 
      printCell();
      printNewLine();
    
    that should produce:
     _______________ // first line
    |_______|_______| // 2 cells and NL
    |_______|_______| // loop
    |_______|_______| // loop
    |_______|_______| // loop
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

Similar Threads

  1. Getting ascii from a String
    By ali_sakar in forum New To Java
    Replies: 1
    Last Post: 03-07-2009, 11:11 AM
  2. Another ascii question....
    By akira220984 in forum New To Java
    Replies: 5
    Last Post: 02-20-2009, 02:38 AM
  3. I need help with ascii characters
    By Grandon in forum Eclipse
    Replies: 17
    Last Post: 11-08-2008, 03:12 AM
  4. Ascii code.........
    By Somitesh Chakraborty in forum New To Java
    Replies: 6
    Last Post: 11-04-2008, 06:32 PM
  5. Loops (while do etc)
    By manupr in forum New To Java
    Replies: 1
    Last Post: 01-15-2008, 04:59 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
  •