Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: help with array assignment ! urgent please :(

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default help with array assignment ! urgent please :(

    I have an issue with understanding array; ive ask my tutor/lect to explain it to me but they rant on another level and thats not helpful to me so I hope somebody here will - especially the last part at the bottom where it ask "// if the pixel for this row and column is a 1"... I am not sure what to put in that section.. any help would be great - ive attached the assignment sheet for reference

    this is my assignment so far:
    ws07.pdfws07.pdf

    import java.util.Scanner;
    import billboard.BillboardInterface;
    import billboard.DigitalBillboardFrame;
     
    /**
     * Partial solution for Stage 1 of the digital billboard
     *
     * @author Darren Jones (10132281)
     * @version 2011 2
     */
    public class ArraysBillboard
    {
            private static final int LETTER_WIDTH = 5;
            private static final int LETTER_HEIGHT = 12;
            private static final int GAP = 1;
     
            private static final int[][] _s =
            {
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0},
                {0, 1, 1, 1, 1},
                {1, 0, 0, 0, 0},
                {1, 0, 0, 0, 0},
                {0, 1, 1, 1, 0},
                {0, 0, 0, 0, 1},
                {0, 0, 0, 0, 1},
                {1, 1, 1, 1, 0},
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0}
            };
     
            private static final int[][] _p =
            {
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0},
                {1, 1, 1, 1, 0},
                {1, 0, 0, 0, 1},
                {1, 0, 0, 0, 1},
                {1, 0, 0, 0, 1},
                {1, 0, 0, 0, 1},
                {1, 0, 0, 0, 1},
                {1, 1, 1, 1, 0},
                {1, 0, 0, 0, 0},
                {1, 0, 0, 0, 0},
                {1, 0, 0, 0, 0}
            };
     
            private static final int[][] _a =
            {
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0},
                {0, 1, 1, 1, },
                {1, 0, 0, 1, 0},
                {1, 0, 0, 1, 0},
                {1, 0, 0, 1, 0},
                {1, 0, 0, 1, 0},
                {1, 0, 0, 1, 0},
                {1, 1, 1, 0, 1},
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0}
            };
     
            private static final int[][] _r =
            {
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0},
                {1, 0, 1, 1, 0},
                {0, 1, 0, 0, 1},
                {0, 1, 0, 0, 0},
                {0, 1, 0, 0, 0},
                {0, 1, 0, 0, 0},
                {0, 1, 0, 0, 0},
                {0, 1, 0, 0, 0},
                {0, 1, 0, 0, 0},
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0}
            };
     
            private static final int[][] _e =
            {
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0},
                {0, 1, 1, 1, 0},
                {1, 0, 0, 0, 1},
                {1, 0, 0, 0, 1},
                {0, 1, 1, 1, 0},
                {1, 0, 0, 0, 0},
                {1, 0, 0, 0, 1},
                {1, 1, 1, 1, 0},
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0},
                {0, 0, 0, 0, 0}
            };
     
        public static void main(String[] args)
        {
            String text;
            Scanner keyboard = new Scanner(System.in);
            // initial size of the display in pixels
            final int WINDOW_WIDTH = 300;
            final int WINDOW_HEIGHT = 120;
            // size of the grid for the digital billboard
            final int BB_WIDTH = 50;
            final int BB_HEIGHT = 30;
     
            // create a billboard
            BillboardInterface billboard = new DigitalBillboardFrame(
                    "SCSS",
                    WINDOW_WIDTH, WINDOW_HEIGHT,
                    BB_WIDTH, BB_HEIGHT);
     
            // we will make letters 5 cells wide and 12 high
            final int LETTER_WIDTH = 5;
            final int LETTER_HEIGHT = 12;
            // and leave a 1 cell gap between letters
            final int GAP = 1;
     
            final int START_X = 11;
            final int START_Y = 8;
     
            String inputText;
     
     
            // first make sure the display is blank
            billboard.allOff();
     
            // forever
            for(;;)
            {
                // get a message from the user
     
                keyboard = new Scanner(System.in);
                System.out.print("Enter a 5 letter word made up of a,e,p,r,s: ");
                inputText = keyboard.nextLine();
     
                // first make sure the display is blank
                billboard.allOff();
                // for each letter in the message
                int x = START_X; 
                int y = START_Y;
     
                writeText(billboard, x, y, inputText);
            billboard.redisplay(0);
     
        }
     
     
     
     
        }
     
     
     
     
     
     
                private static void writeText(BillboardInterface billboard, int x, int y, String text)
                {
                    for(int i = 0; i < 5; i++)
                {
                 writeLetter(billboard, x, y,(text).charAt(i));
                     x += LETTER_WIDTH + GAP;    
                }
                }
     
                private static void writeLetter(BillboardInterface billboard, int x, int y, char c)
                {
                        // display the i_th letter
                    switch(c)
                    {
     
                        case 's': 
                        write_s(billboard, x, y);
                        break;
     
                        case 'p':
                         write_p(billboard, x, y);   
                        break;
     
                        case 'a':
                        write_a(billboard, x, y);
                        break;
     
                        case 'r':
                        write_r(billboard, x, y);
                        break;
     
                        case 'e':
                        write_e(billboard, x, y);
                        break;
                        default:   
                }
            }
                private static void write_s(BillboardInterface billboard, int x, int y)
                {
                        billboard.turnOn(x+1, y+2);
                        billboard.turnOn(x+2, y+2);
                        billboard.turnOn(x+3, y+2);
                        billboard.turnOn(x+4, y+2);
                        billboard.turnOn(x, y+3);
                        billboard.turnOn(x, y+4);
                        billboard.turnOn(x+1, y+5);
                        billboard.turnOn(x+2, y+5);
                        billboard.turnOn(x+3, y+5);
                        billboard.turnOn(x+4, y+6);
                        billboard.turnOn(x+4, y+7);
                        billboard.turnOn(x, y+8);
                        billboard.turnOn(x+1, y+8);
                        billboard.turnOn(x+2, y+8);
                        billboard.turnOn(x+3, y+8);
                }
                private static void write_p(BillboardInterface billboard, int x, int y)
                {
                        billboard.turnOn(x+1, y+2);
                        billboard.turnOn(x, y+3);
                        billboard.turnOn(x, y+4);
                        billboard.turnOn(x, y+5);
                        billboard.turnOn(x, y+6);
                        billboard.turnOn(x, y+7);
                        billboard.turnOn(x, y+8);
                        billboard.turnOn(x, y+9);
                        billboard.turnOn(x, y+10);
                        billboard.turnOn(x, y+11);
                        billboard.turnOn(x+4, y+3);
                        billboard.turnOn(x+4, y+4);
                        billboard.turnOn(x+4, y+5);
                        billboard.turnOn(x+4, y+6);
                        billboard.turnOn(x+4, y+7);
                        billboard.turnOn(x+1, y+8);
                        billboard.turnOn(x+2, y+8);
                        billboard.turnOn(x+3, y+8);        
                        billboard.turnOn(x, y+2);
                        billboard.turnOn(x+2, y+2);
                        billboard.turnOn(x+3, y+2);
                }
                private static void write_a(BillboardInterface billboard, int x, int y)
                {
                        billboard.turnOn(x, y+3);
                        billboard.turnOn(x, y+4);
                        billboard.turnOn(x, y+5);
                        billboard.turnOn(x, y+6);
                        billboard.turnOn(x, y+7);
                        billboard.turnOn(x+1, y+2);
                        billboard.turnOn(x+2, y+2);
                        billboard.turnOn(x+3, y+3);
                        billboard.turnOn(x+3, y+4);
                        billboard.turnOn(x+3, y+5);
                        billboard.turnOn(x+3, y+6);
                        billboard.turnOn(x+3, y+7);
                        billboard.turnOn(x+1, y+8);
                        billboard.turnOn(x+2, y+8);
                        billboard.turnOn(x+4, y+8);
                }
                private static void write_r(BillboardInterface billboard, int x, int y)
                {
                        billboard.turnOn(x, y+2);
                        billboard.turnOn(x+1, y+3);
                        billboard.turnOn(x+1, y+4);
                        billboard.turnOn(x+1, y+5);
                        billboard.turnOn(x+1, y+6);
                        billboard.turnOn(x+1, y+7);
                        billboard.turnOn(x+1, y+8);
                        billboard.turnOn(x+2, y+2);
                        billboard.turnOn(x+3, y+2);
                        billboard.turnOn(x+4, y+3);
     
                }
                private static void write_e(BillboardInterface billboard, int x, int y)
                {
     
                        billboard.turnOn(x, y+3);
                        billboard.turnOn(x, y+4);
                        billboard.turnOn(x, y+5);
                        billboard.turnOn(x, y+6);
                        billboard.turnOn(x, y+7);
                        billboard.turnOn(x+1, y+8);
                        billboard.turnOn(x+2, y+8);
                        billboard.turnOn(x+3, y+8);
                        billboard.turnOn(x+4, y+7);
                        billboard.turnOn(x+1, y+5);
                        billboard.turnOn(x+2, y+5);
                        billboard.turnOn(x+3, y+5);
                        billboard.turnOn(x+1, y+2);
                        billboard.turnOn(x+2, y+2);
                        billboard.turnOn(x+3, y+2);
                        billboard.turnOn(x+4, y+3);
                        billboard.turnOn(x+4, y+4);
     
     
     
                }
                private static void writeArray(BillboardInterface billboard, int x, int y,int[][] pixels)
                {
                    for(int row = 0; row < pixels.length; row++)
                    {
                        for(int col = 0; col < pixels[row].length; col++)
                        {
                            // if the pixel for this row and column is a 1
                            // then call turnOn for the grid cell that
                            // corresponds to this pixel
                        }
                    }
                }
            }
    Last edited by helloworld922; September 27th, 2011 at 12:09 AM.


  2. #2
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: help with array assignment ! urgent please :(

    Well, i think, you must understand what comments mean. Do you have any turnOn function?
    If yes, this function will must taking two parameters, row and column. Just pass them to the function. And call that function here.
    I don't know if your problem is with understanding of the code or your intention is to let someone do your assignment?
    And is this your own written code? Well, i guess, NO!!!

  3. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,357
    My Mood
    Hungover
    Thanks
    144
    Thanked 626 Times in 537 Posts

    Default Re: help with array assignment ! urgent please :(

    Please read this: How to Program (stuck on homework? READ THIS BEFORE POSTING) as well as the link in my signature on asking questions the smart way.

    Basically, complaining about your instructor and mentioning your urgent delays makes you seem lazy (many people here learned without the benefit of a classroom at all) and selfish (there are hundreds of posts here, each with an urgent user behind it, and your time is not more valuable than theirs), and actually decreases your chances of getting help.

    Follow the guidelines in the links I gave you, and we'll go from there.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    Junior Member
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: help with array assignment ! urgent please :(

    man all i wanted is someone to help me UNDERSTAND what is ask at the section // if the pixel for this row and column is a 1 section in my assignment -__- that is all. you can call me selfish or lazy or whatever but it doesn't prove anythin because i'm asking for someone to EXPLAIN not DO if you don't believe this is mine than why bother comment ? seriously read my plead above properly before you judge. I just need someone to explain array and how to apply it to the section im having an issue with; not to be push down. this is only stage4 i got 2 more stages to do by 26th of october. anyways KevinWorkman - thanks for the link ! sorta help.

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,357
    My Mood
    Hungover
    Thanks
    144
    Thanked 626 Times in 537 Posts

    Default Re: help with array assignment ! urgent please :(

    Well, this post contains a lot of things that irks people- you've posted way too much code, you attached you assignment, you complained about your teacher, you mentioned your urgency, and you didn't really ask an actual question. So people are going to hesitate to just give you an answer.

    Hint: That nested for loop is iterating over each index of the 2d array. Try putting some print statements in there, or better yet, step through it with a debugger, to figure out what it's doing.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. #6
    Member
    Join Date
    Jul 2011
    Posts
    33
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: help with array assignment ! urgent please :(

    Which part of the program can you get to work? A program is the shortest path from input to output. For starters, did you load your starting data correctly? Can you prove it with a System.out.print? If yes, comment out the print with // and go on to the next step. Repeat this process until you get stuck on a particular statement. THEN write a post to here. Quote the particular statement. Say what inputs it had. Quote the compiler's error message or describe the behavior which was incorrect, but did not crash the program or prevent compilation.

    Please make it as easy for us to understand what went wrong. Remember we have our own problems--that's why we are here. Even now, I'm contemplating how to present my problem in a way that does not seem really whiny and helpless, though that is the way I feel.

    Have you tried getting a study group together with other students? If you have problems, your colleagues have tham as well. If a half dozen of you can knock heads together, you improve your chances of finding an answer all of you understand.

    good luck & keep it brief

Similar Threads

  1. URGENT!!!! help with array element comparing
    By Neo in forum Java Theory & Questions
    Replies: 3
    Last Post: March 3rd, 2011, 07:52 AM
  2. Need urgent help in assignment of JAVA, any idea suggestion plz
    By aesthete in forum Java Theory & Questions
    Replies: 2
    Last Post: January 6th, 2011, 04:58 AM
  3. Urgent help required - converting image to array
    By Paulious in forum Algorithms & Recursion
    Replies: 0
    Last Post: September 1st, 2010, 06:24 AM
  4. nid help for my assignment~urgent
    By x3ahbi in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 5th, 2010, 02:55 AM
  5. Multi Dimensional Array help NEEDED URGENT
    By bonjovi4u in forum Loops & Control Statements
    Replies: 5
    Last Post: February 12th, 2010, 11:44 PM