Two dimensional pattern question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mia023
    New Member
    • May 2007
    • 89

    Two dimensional pattern question

    I just wana ask u about how to write a program that prints 2 dimensional N by N pattern with alternating spaces and asterisks.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by mia023
    I just wana ask u about how to write a program that prints 2 dimensional N by N pattern with alternating spaces and asterisks.
    Please read the posting guidelines before posting further.

    Comment

    • mia023
      New Member
      • May 2007
      • 89

      #3
      Originally posted by r035198x
      Please read the posting guidelines before posting further.
      i just need the sequencial logic for writing the program and not the whole program please i only need just some hints

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        I also changed this topic's title: 'Urgent" is not an appropriate topic title. Talking
        about urgent: why is this so urgent?

        kind regards,

        Jos

        Comment

        • mia023
          New Member
          • May 2007
          • 89

          #5
          can u just give me some hints Please

          Comment

          • JosAH
            Recognized Expert MVP
            • Mar 2007
            • 11453

            #6
            Originally posted by mia023
            can u just give me some hints Please
            Watch closely because the following is much more than a hint; it's a complete
            giveaway:

            [code=java]
            private static boolean isStar(int x, int y) { return true; }

            private static void square(int N) {
            for (int x= 0; x < N; x++) {
            for (int y= 0; y < N; y++)
            System.out.prin t(isStar(x, y)?'*' : ' ');
            System.out.prin tln();
            }
            }
            [/code]

            The isStar() method returns true when at a certain position x, y a star should be
            printed; otherwise it returns false. My implementation is a dummy implementation.

            The square() method prints a square of size N. It consults the isStar() method for
            every position x,y whether or not it should print a star or a space.

            Now all you have to do is come up with a correct implementation of the isStar()
            method.

            kind regards,

            Jos

            Comment

            Working...