Well, at a really simple level, here's how I would approach it.
- Have 2 flat files that have two columns. One is the seat number, the other is "Available" or "Unavailable". One file is for First Class, one for Coach.
- When the person requests first class or coach, use a BufferedReader to read in the appropriate file. Use a StringTokenizer to break apart the
String read from each line, and create a Map that has mappings between seat number to availability (Integer object to String object mapping).
- Work with the maps until the person confirms their seat. Once that is done, use a PrintWriter to write out each mapping to a line.
The
I/O API gives the descriptions of these classes. The only methods you need for input/output are BufferedReader.readLine() and PrintWriter.println( String ).