Paul Nguyen

Greenhorn
+ Follow
since Nov 02, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Paul Nguyen

Oh, we don't need to evaluate the expression for this project, just to convert the notation. My class already did postfix evaluation in a past project already. I've finished this project already, and thanks for the help Campbell.
10 years ago
I just reuse one stack. After each method is done I clear it with stack.clear();

my infix to postfix algorithm is now like this, and my infix string will add an extra set of matching parenthesis on the ends "(" + inFix + ")"

if (parenthesis does not match)
return (error in infix expression)
else
continue to convert infix to postfix method
10 years ago
I think I've got it, but I created another method to check the parenthesis instead and then have it give me a boolean answer so I could implement it to my other method.

Edit: I've been taught to put System.exit(0) at the end of my programs, so I'm just going with it for now. Is it that bad to use?




10 years ago
Alright, my brain is almost fried after hours of thinking and trying to get this to work, I was able to get my program to work with correct input, but I can't seem to get my program to catch extra parenthesis errors or errors in the infix notation. Help please



using this as a test program/driver, errors are described in comments:


any ideas on improving/simplifying the algorithm would be nice too, because mine looks like a mess :/

Edit: fixed one problem for input str7. Still working the rest...

10 years ago

Rob Prime wrote:Just call repaint() on jPanel. This will call it's paint method which calls paintComponent which calls ep.paintEntryPanel.



Oh my god, was that all I had to do? Thanks. It works now.
Now I just got to finish up the rest of the project. Thanks a bunch Rob!
10 years ago
I'm trying to make a program which calculates the distance between two points which the user gives by clicking on the JPanel. After the points are clicked, dots will be drawn on the points where the users clicked, lines will be drawn to mark the paths, and updates the appropiate JLabels using the Pythagorean theorem and Manhattan distance formulas.

The problem is how do I call my paintEntryPanel method with my graphics argument without having to call initComponents() all the time, because it screws up the display by placing components over each other. I've tried using setters to pass the graphics argument to a global variable, but that doesn't work. I've been taught to use a custom creation code on the JPanel, but I'm not really sure how or why it works and now I'm completely stuck on how to fix the code so I can separate the jPanel and draw function.
Any help would be greatly appreciated.


10 years ago