Greetings people who may read this! It is I, RudeGuyGames, who has finished his programming class and actually learnt what the hell an object is and how one would go about using one for anything!

I must confess: I was a bit concerned about the class being taught using Java, but it seems like it wasn’t such a bad thing, after all; I have properly learnt what polymorphism is, and I have already been able to make my own code in C++ utilizing polymorphic techniques, including virtual functions and abstract classes. I can safely say that learning Java before continuing my efforts in C++ have greatly simplified the process. As for what I will make in the future: that remains to be seen.

My project has gotten a little farther. It’s not really much to speak of, as it’s more of a GUI practice thing than anything. I’d like to learn FXML so I can make interfaces which don’t look like a pile of shit. I mean, just look at it:

Look at that! It’s hideous! I can’t make a proper user interface because all the JavaFX layouts are made for is apparently just simple stacking and various table-based placements of simple GUI nodes.

I mean, for fuck’s sake, I can’t even add borders because I don’t even know how to do that without some sort of markup language. That’s why I would like to learn FXML, except I have been stalling since it looks like an absolutely horrible mess:

Okay, maybe it’s not that bad, but do I really want to bother learning another language? Wait… that’s what I said I needed to do. Maybe. Implicitly.

Disregarding the fact that I still haven’t uploaded that program anywhere and that it’s on a laptop that may break any time soon and, indeed, that I don’t even know where it’s saved on said laptop, I have begun work on a Java version of that program, except the user will now be able to input his/her expression in a GUI.

The only difference between my shabbily cobbled-together C++ parser, this one actually uses a slightly less improvised method, namely the shunting-yard algorithm. So far, I have been able to make at least half of the program; it can turn a no-space string of numbers, operators and parentheses/brackets into an array of strings in reverse Polish notation.

It may not be the most efficient way of implementing it, but my class is pretty cool. It even has a private inner class and stuff for fetching the next token! Okay, perhaps that’s not really the greatest feat ever, but I still like how it turned out.

REMEMBER: IT’S STILL A HELL OF A LOT BETTER THAN THAT ABSOLUTE MESS I MADE LAST TIME I TRIED DOING SOMETHING LIKE THIS.

Anyway, here are some examples of outputs returned by the shunting-yard interpreter or whatever one should name it:

The user inputs, e.g., “3+5*(2+3-(3*4/2+4))” in some input field somewhere.

The shunting-yard algorithm I wrote breaks this down into a simple array of numbers and operators.

The array is output elementwise.

As an example, here’s how this algorithm works in the first case:

Input:"3+5*(2+3-(3*4/2+4))"
1. Read first input character. This is a number. Check if next index is
also a number. It isn't.
2. Add this number to the output array.
3. Read the next input character. This is an operator. Check if there
are other operators in the operator array. There aren't.
4. Add this operator to the operator array.
5. Read next input character. This is a number. Check if next index is
also a number. It isn't.
6. Add this number to the output array.
7. Read the next input character. This is an operator. Check if there
are other operators in the operator array. There are. Check
if the operator has a higher precedence than the last operator
in the operator array. It does.
8. Add this operator to the operator array.
9. Read the next input character. This is an opening bracket. Add it
to the operator array.
10. ... Add "2" to the output array.
11. ... Add "+" to the operator array.
12. ... Add "3" to the output array.
13. ... Add "-" to the operator array.
14. ... Add "(" to the operator array.
15. ... Add "3" to the output array.
16. ... Add "*" to the operator array.
17. ... Add "4" to the output array.
18. ... Add "/" to the operator array.
19. ... The operator "+" has a lower precedence than the operator currently
the last operator ("/"). Therefore, move "/" to the output array,
then add "+" to the operator array as the new operator of highest
precedence.
20. ... Add "4" to the output array.
21. ... The operator ")" is a closing bracket. Add all entries in the
operator array from the top down to the output array until a closing
bracket is encountered.
22. Remove both brackets.
23. ... The operator ")" is a closing bracket. Add all entried in the
operator array from the top down to the output array until a closing
bracket is encountered.
24. Remove both brackets.
25. END OF INPUT; add remaining operators in the operator array from the
top down to the output array.
26. ALGORITHM END.
Output: 3 5 2 3 3 4 2 / * 4 + - + * +

Then we can read the output and calculate the result as follows:

Find the first operator.

Take the two numbers before the operator and replace the two numbers and the operator by the result “[FIRST_NUMBER] [OPERATOR] [SECOND_NUMBER]”.
Example: 10 2 / = 10/2 = 5.

That’s pretty much how the shunting-yard algorithm works, and all I really need to do is figure out how to handle the last half of the algorithm. Well, actually, I have already done the algorithm itself; I just need to work with the output and display the answer to the input expression.

That said, this has been going on for way too long. I think it’s time to end this here. Hopefully all goes well. It sure has gone better than my last attempt.

And, yes, I did try doing this more than once in Java. In fact, I tried my old method before I found this. Seems like I need to use Google more and not refrain from looking for tips on the Internet like a wannabe-independent twonk.

I fixed the problem described in my previous blog post. It was quite a simple fix, actually. It involved going on Google and typing “NetBeans”, subsequently downloading an exemplar of the program whose name is equivalent to said search query and using this program to compile an executable .jar file instead. Now my .jar file’s size got lower than ever, at a staggering 5, count them: FIVE, kilobytes!

Moral of the story: NEVER use [REDACTED].

And, yes, I know I am utterly inept at this stuff, but I really just want to code. I have not yet arrived at the “programming” part yet.

Why is it that there has to be at least fifty issues beyond any possible explanation whenever it comes to exporting my files? Seriously, I just want to export my files, but I now notice that every time I export my package to a runnable .jar file, the exported .jar file doubles in size for every export made. What the fuck?

Seriously, I just want to export my fucking program! That means I want to create A CLEAN .JAR FILE with NO USELESS GARBAGE exported along with it. BUT NO! Let’s just throw in as much old shit at possible because it’s hard to export properly!

Here’s how I export:

In Eclipse, I go to File –> Export…;

I select the stupid “Runnable JAR file” option that apparently doesn’t work properly;

I make sure my current launch configuration is my current package and save the exported .jar file as a new file in whatever place I wish;

and, since I don’t know what the fuck the other options are, I finally just proceed to export the piece of shit.

???

NOT PROFIT! I go to look at the fucking file,and it’s two times bigger than the file that was generated last time I exported the exact same fucking program as a runnable .jar file! GOOD JOB.

If anyone reads this, could you please explain what the hell is going on? Googling this turns up nothing because reasons. The reason this is an issue is because I just finished the third program in the Google Code Jam for the “Africa 2010 Qualification Round” (T9 Spelling), and it happens to be in the same package as all the other things. But, seriously, what the fuck do the .jar files double in size every export for?

Another Google Code Jam entry of mine is available under the RGG’S PROGRAMS –> Java menu. This time, it’s the “Store Credit” challenge. Once again, I have not followed the problem text to a tee, and, once again, I don’t give a shit.

Making it was alright. It was a bit finicky, but I managed to pull through. Good. Just make sure not to input any negative numbers or anything; I haven’t quite managed to handle my exceptions yet. Fuck exceptions. The only exceptions I need are the exceptions to my programming experience due to its uselessness.

Just stopping by to note that I have begun doing shit on my own. Not really going to be doing any programs with GUIs or anything in the near future for various reasons. Anyway, I found some practice problems on Google Code Jam, and I have already done one of them, although I followed the problem loosely, i.e. not printing text verbatim according to the problem text. Whatever.

Anyway, if you want to run the thing for yourself, the .jar file and its accompanying batch file for quick Windows launching can be downloaded here. Once again, if Google scans this and finds that it needs to mark this as a malicious file, it can go straight to hell.