views:

148

answers:

3

I'm doing formal method and one of the project is to create a finite machine interpreter using java.it needs to read NFA from a text file and then convert from NFA to DFA. It also needs to output DFA to a text file.Then it goes to run through the symbol input and process DFA showing result whether accept or reject.

I don't have much of a problem with coding but with the design.I mean to get a nice smooth way of implementing it.What should I get started?and what classes should i have?

+1  A: 

One way to design an application is to look at the problem and describe the solution in English. Describe each and every step, including any assumptions you notice along the way. Each paragraph probably should be a different method. Methods that do very similar work should be classes.

So, can you update your answer to verbally describe, in paragraph form, what your program needs to do?

Oh, and just to give a little hint: when you describe the NFA/DFA in paragraph form, try describing it as if you were going to draw a picture (you can replace the "draw" work with something, later, in the actual application, but it can be a nice placeholder for now)

atk
A: 

I would base the design on how the Stream classes work. You could have an NFA input stream and a DFA output stream. Then a converter class could use an instance of each.

David
+1  A: 

You might re-write the "Encoder" I use to create mine.

I designed it to take a finite state table (laid out in code), but I abstracted the parser pretty well and you could just rewrite that portion, the rest of the classes should work pretty well as is.

http://code.google.com/p/state-machine/

Bill K