Results 1 to 3 of 3
  1. #1
    chen8735 is offline Member
    Join Date
    Mar 2008
    Posts
    1
    Rep Power
    0

    Default anyone can give idea 2 my assignment?

    Create a GUI program to trace out any braces and keep track of the line having wrong closure of any

    braces dynamically and identify the previous line typed if error prone note some red symbol in the

    marigin. The marigin however must dynamically increase the line count of the coding.

  2. #2
    Tocs1001 is offline Member
    Join Date
    Mar 2008
    Posts
    1
    Rep Power
    0

    Default

    By braces do you mean [ { ( ???
    Your "assignment" is so vague...
    Do braces close between lines such as...

    Java Code:
    {Blah blah
    blah}
    or just on each line..?

    If anything is remotley similar your going to want to use a stack...

    Everytime you find an open brace put it on the stack
    if you find a closing brace. Make sure it matches the brace type, [ { (, if it does pop the top of the stack off. By doing this if you encounter a brace that does not match or reach the end of the file / line depending on the problem you know you have an error!

    Example

    given "[Lol is some text[fun]]"

    Stack goes adds a [ stack is now "["
    It skips over non-brace characters it finds another [ adds it to the stack. stack is now "[[" It continues skipping over more non brace characters. It finds a ] so it compares it to the top of the stack "[" they are the same type so it pops it off. Stack is now "[" it finds another ] it matches the top of the stack. So it pops it off. Stack is now " ". End of file...Text is fine!

    given "[LOL some text..again [heh]"

    Stack finds a [ adds it. Stack is now "[". Continues skipping non-brace characters. It finds another [. Adds it to the stack. Stack is now "[[" it continues skipping non-braces. it finds a ]. It matches the type of the top of the stack. Top of stack is removed. Stack is now "[". End of file/line. The stack is left with "[" there is an error.

    Hope this helps....

  3. #3
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    9

    Default

    Chen, please provide us your attempt at your own code- make a valid effort and many of us would be happy to assist. I know you said "ideas" but if you simply get started on your code, you will be surprised sometimes how ideas come to you- then if you run into problems let us know.

    To both of your, welcome to the Java Forums! :)
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

Similar Threads

  1. Got an Idea, Just Share it!
    By james in forum Java Software
    Replies: 0
    Last Post: 03-18-2008, 01:09 PM
  2. Need a idea on GridBagLayout
    By ddsuresh in forum AWT / Swing
    Replies: 1
    Last Post: 01-29-2008, 02:32 AM
  3. Replies: 0
    Last Post: 01-19-2008, 10:04 AM
  4. i couid not get the idea:
    By sivasayanth in forum New To Java
    Replies: 2
    Last Post: 01-18-2008, 06:52 PM
  5. give me a advise
    By sireesha in forum New To Java
    Replies: 3
    Last Post: 12-11-2007, 02:38 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
  •