Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!

Knute Snortum

+ Follow
since Apr 20, 2013
Knute likes ...
Chrome Eclipse IDE Java Postgres Database VI Editor
After 25 years of programming, Knute has retired to be a professional musician. Knute first learned BASIC and Cobol on a CPM Timeshare system circa 1985. He spent way too long coding in one flavor of Business Basic or another. Going back to college, he learned C and a whole new world opened up to him. Knute likes Perl and Java, for completely opposite reasons. Knute is a complex person.
Portland, Oregon
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Knute Snortum

I'm not sure what the problem is on first inspection, but I am hampered by the poor formatted and unmatched braces in the code.  Here are a few suggestions:

  • Format your code in an IDE and repost.  If you look at HowToFormatCode (that's a link) near the bottom, there are keyboard shortcuts to reformatting your code in major IDEs.
  • Post your full code to GitHub or similar websites, or maybe better...
  • Create an SSCCE (that's a link) that demonstrated the problem.  This will often lead to a solution.

  • I will start writing an SSCCE if I have time.  
    9 hours ago
    You would use the table name in front of the column name, like table_name.column_name.  So...
    @OP: This will definitely require String manipulation.  To see what you can do with a Java String object, google java 11 string api.  (The "11" can be whatever version of Java you have.)  You could also use RegExes, but hopefully not, since this is not a beginning concept.

    So to clarify, the text file might look like this:

    title:Rare Books
    It is *very* important that our copy of %Moby Dick% be preserved.

    and it would create this output:

    I would start writing out all of the steps you would take to do this in plain English.  Like...
  • If the text starts with "title:", remove "title:" and surround the remaining text with <title> opening and closing tags
  • If a line of text contains an asterisk, remove it, search for the next asterisk, and place the text between them inside <b> opening and closing tags

  • etc.

    It's also going to be important to know if you can assume that the text is well-formed.  So for instance, if you encounter an asterisk, will there be another to find?  Could it be on the next or proceeding lines?  Things like that.

    By the way, this is not a simple assignment.
    14 hours ago
    @OP: Be sure to create your thread with a meaningful subject line.  "Need help with ideas" doesn't tell us anything.  I changed it for you this time.
    14 hours ago
    I would think a better solution would be to setup a web.xml file.
    15 hours ago
    Thanks for posting the solution.
    1 day ago

    Josip Skako wrote:Now I am  thinking to use text file as "Temp" and on return from Class2 to Class1 read variable from text file

    Don't do that.  I know we can find a better way.

    In the original post, Josip Skako wrote:I have 2 classes ("Class 1" and "Class 2"). Both of classes has "GUI".

    It is tricky passing a value from one class to another in Swing.  I know how to do it in JavaFX but maybe it's different in Swing.  I've added this thread to the Swing forum to see if people there might have an idea how to do this.

    So the first thing to do is to tell us the real names of Class1 and Class2 and how are they used, what's their relationship, how they are launched, etc.
    1 day ago
    I'm not sure I understand.  Is it the (t*4)+i+1 part you need an explanation for?  If so, Carey has done a good job.  If it is the ar[t][i] part, then the "ar" is the array object, [t] references the t-th element in ar (which itself is an array), and [i] references the the i-th element in [t].

    An illustration might help here:

    ar[0] references array 0
    ar[1] references array 1

    ar[0][0] references the 0 element in array 0
    ar[0][1] references the 1 element in array 0
    ar[1][0] references the 0 element in array 1
    ar[1][1] references the 1 element in array 1
    2 days ago
    Tell us what book that code is from, to prevent copyright problems.
    2 days ago
    Welcome to the Ranch, Mohamed Ragab!

    When posting code, be sure to UseCodeTags (that's a link).  I've done it for you this once.

    If this code is not yours, quote the source to prevent possible copyright problems.
    2 days ago
    Welcome to the Ranch, boe john!

    Debugging a class with variable names like x1, y2, etc. is very difficult for the author and nearly impossible for anyone else!  If you're using an IDE, use its Rename function and slowly name variable something that is describes their function.  x5 might be renamed pieceColorPrompt, for instance.

    I know this doesn't solve your problem directly, but you will find that this process makes debugging much easier.

    Some other tips:
  • Don't write if (something == true), just write if (something)
  • Class names should begin with an uppercase letter
  • Don't call a method recursively when you don't need recursion (example: line 52)
  • 2 days ago
    Parent POMs only have packaging of "pom" (I believe).  That's why you need two child POMs: one that has jar packaging and one that has war.
    2 days ago
    You would need to create "getter" methods for your fields in Class2, like so:
    Then you could use them with a Class2 object:
    Also note that variables should start with a lowercase letter.
    2 days ago
    Thanks for posting the solution!
    2 days ago