Say I am reading in a text file that has String codes that represents rows of seats on an aircraft.
Here is what a line from the file would look like -
1A XXX XXX XXX 1D 1G XXX XXX XXX XXX 1J 3A XXX XXX XXX 3D 3G XXX XXX XXX XXX 3J XXX XXX XXX XXX XXX XXX XXX XXX XXX 8H 8J 9A 9B XXX XXX 9D 9E 9G XXX XXX 9H 9J
The alphanumeric code refers to an airline seat, the "XXX" refers to a non-seat (aisle).
So you can gather from this snippet that if a token contains an "A" or "J", it's a window seat.
But, what is the best way to see if it's an aisle seat? The only way I can think of to check if the token is an aisle seat is that if the current token represents a seat, but the next token is "XXX", OR the last token was "XXX", it's an aisle seat.
I am not sure how I would program that though. I represent the current token using
So, the current token is represented as lineScan.next(). If I want to compare word with a previous or upcoming token on the line, how would I do that?
Would an if statement like this valid?
I am guessing that could read the next token, but I want to make sure I am not moving the scanner to the next token by doing that.
Really, I am just stuck here and would like some guidance.