Last part of java assignment *whew*

mdchesne

Banned
Feb 27, 2005
2,810
1
0
duragezic, hope you see this since i know you're already done :)

link to assignment
So I got the first part working thanks to you and a couple others here at Anandtech (thanks guys), but how or where did you put your recursion to finish off step two? If we are to read a second line in Input.txt, should I make another tokenized string outside of the "try"?

(BTW, final test to see if stack is empty from first part... still doens't work for me...placement?)
 

duragezic

Lifer
Oct 11, 1999
11,234
4
81
Well, it's up to you, it doesn't really matter.

I have my main() method to just call a withStack() and withRecursion() methods to do the work and output. My withStack() returns the character array that I pass a reference to withRecursion(). Since the work was already done in withStack() in parsing the input, I figured to just use the same array, no need to re-Tokenize anything.
 

mdchesne

Banned
Feb 27, 2005
2,810
1
0
did you need to put the withStack() methods in another class or how did you add them under main? I'm trying to add subclasses with methods that would do something along the lines of what you were syaing, but i keep getting 'class' or 'interface' expected
 

duragezic

Lifer
Oct 11, 1999
11,234
4
81
I did it like this:


public class ParenthesisMatch
{
public static void main() {}
public static char[] withStack() {}
public static void withRecursion() {}
}

<Stack and Node classes after>