• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bracket matching using an Array Deque and reading a text file  RSS feed

 
Sofia Pineda
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:


 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!