Results 1 to 16 of 16
  1. #1
    ace_03 is offline Member
    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0

    Default help with parsing

    A private method isWellFormed(String):boolean. This method checks the length of its parameter value and, if correct (7), parses the characters in the String to confirm that they are 1s or 0s exclusively. The method returns boolean true if the parameter is well-formed, false otherwise.

  2. #2
    ace_03 is offline Member
    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0

    Default

    public static final int NUM_BITS = 7;
    public String bit;
    public static boolean EVEN = true;
    public static boolean ODD = false;

  3. #3
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Yes? Do you have a question?
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  4. #4
    ace_03 is offline Member
    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0

    Default

    yes. i wanted to write a method to parse.
    A private method isWellFormed(String):boolean. This method checks the length of its parameter value and, if correct (7), parses the characters in the String to confirm that they are ‘1’s or ‘0’s exclusively. The method returns boolean true if the parameter is well-formed, false otherwise.

    but im stuck?
    could u help me code it

  5. #5
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Of course I can help you. Post your code and we'll see what goes wrong.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default

    The regular expression "[01]{7}" mathes your wanted String value exactly.

    kind regards,

    Jos

  7. #7
    ace_03 is offline Member
    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0

    Default

    public static final int NUM_BITS = 7;
    public String bit;
    public static boolean EVEN = true;
    public static boolean ODD = false;

    private boolean isWellFormed(String parityString){
    return parityString.matches("[01]{7}");
    }

  8. #8
    ace_03 is offline Member
    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0

    Default

    i know its wrong. i dn't know where to go from here

  9. #9
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Ahem what is wrong? That looks perfect to me.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  10. #10
    sky
    sky is offline Member
    Join Date
    Nov 2009
    Posts
    96
    Rep Power
    0

    Default

    Maybe some identation in the return... Just kidding

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by PhHein View Post
    Ahem what is wrong? That looks perfect to me.
    I don't know what's supposed to be wrong either; but I've been known on staring to my terminal for quite some time, mumbling and scribbling secret notes and not finding an obvious bug ;-)

    kind regards,

    Jos

  12. #12
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Maybe its wrong in the sense of: use loops to implement the method or something like that :confused:
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  13. #13
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by PhHein View Post
    Maybe its wrong in the sense of: use loops to implement the method or something like that :confused:
    Or maybe this is a 'Hidden Restriction Question', where the OP sends everybody into the void as in 'hi, I'm running an applet and I want to use my database in Netbeans and Swing and a Jtable needs to be unique among all JSPs while my client is offline but now I get "illegal start of expression"' ... after a long list of replies going nowhere, the OP posts: 'b.t.w. I am only allowed to use arrays' ;-)

    kind regards,

    Jos

  14. #14
    ace_03 is offline Member
    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0

    Default

    how would u do with loops?

  15. #15
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,336
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by ace_03 View Post
    how would u do with loops?
    I wouldn't; I'd use a simple regular expression for the purpose and let it handle the nasty looping itself. But if you insist in doing things the primitive way read the API documentation for the String class and pay special attention to it's length() and charAt( ... ) methods; you'll need them.

    kind regards,

    Jos

  16. #16
    ace_03 is offline Member
    Join Date
    Nov 2009
    Posts
    8
    Rep Power
    0

Similar Threads

  1. Parsing XML
    By virvalid in forum Advanced Java
    Replies: 3
    Last Post: 08-10-2009, 12:40 PM
  2. Parsing
    By Matt Sakko in forum New To Java
    Replies: 14
    Last Post: 03-21-2009, 04:49 PM
  3. Xml Parsing
    By Nomad in forum XML
    Replies: 12
    Last Post: 02-22-2009, 11:19 AM
  4. xml parsing help
    By tankhardrive in forum XML
    Replies: 2
    Last Post: 02-11-2009, 11:45 PM
  5. Parsing URL
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-26-2007, 10:16 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
  •