Forums Register Login

Bracket matching using an Array Deque and reading a text file

+Pie Number of slices to send: Send
Hi, I would appreciate your help on this assignment. I am trying to match brackets implementing an ArrayDeque for the iterative method. I have trouble with the following, and I have tried answering these questions within my code (most don't work).

1. within the method, should I open the file and read it even if it is already in main? If so, how do I do this again?
2. how to check that the present character read is equivalent to the type of open bracket?
3. how can I save the location of each open bracket (and corresponding closing bracket) such that if there is an error, I can provide a throw/exception indicating the place where the mismatch occurred.
4. how can I assimilate the opening and closing brackets, of the same type?!?!
5. if stack is not empty, I should also throw an exception, but shouldn't this be the same as 3?

I would greatly appreciate some help and insights on my problems! Thanks! =)

This is my code so far:


This is the code we have been provided for reading a character:


Code for how to use getOneCharacter and throw an exception:


and finally, the main within myassignment class to open the files:


Well behaved women rarely make history - Eleanor Roosevelt. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2520 times.
Similar Threads
plz delete
Code critique: CSV to Tab-delimited
Lucene beginner question
Java Calculator problems
How to divide File in Java
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:13:41.