CSCI 1302 Programming Project 2 Summer 2008 DFA Simulator This program is due by midnight on *** Sunday, June 29. *** A DFA (Deterministic Finite Automaton) M is a basic model of a real-time computing system. It has a fixed finite number of states it can be in, it is always in one of those states, and it processes a string of symbols (or word -- to distinguish it from one possible representation, the Java String) one symbol at a time. These symbols are drawn from a fixed finite set called the alphabet. The combination of current state and next input symbol determines the next state uniquely (hence M is termed deterministic). M reads one symbol per step, always left to right, until it has read every symbol. Exactly one of the states is the initial state; the DFA starts in that initial state when processing any word. Some of the states (any, all, or none) are designated as final states. If the processing of w leaves the DFA in a final state then it accepts w; otherwize it rejects w. In this assignment you will implement a DFA simulator which will read a specification of a DFA M_from_file from a file dfa_spec, and write a file accepted_words containing the words of length <= n which are accepted by M_from_file. *The class containing main( ) should be called SimDFA, and the action just described should be taken when you execute the command "java SimDFA dfa_spec n accepted_words". *The input file dfa_spec is assumed to be a text file of the following form: alphabet: s1 s2 s3 ... sk q1 p11 p12 ... p1k [initial] [final] q2 p21 p22 ... p2k [initial] [final] .................................... qr pr1 pr2 ... prk [initial] [final] Here s1, s2, etc represent distinct printable characters separated by spaces, all on the first line after "alphabet: ", so k is the size of the alphabet; there are r states, q1 to qr, and one row of the file for each state; the states consist of r distinct nonempty strings without white space; in the row starting with qj the entry pjm is the next state for M_from_file when symbol sm is processed from state qj; []'s do not appear in the file, but indicate optional entries, of course with the [initial] option exercised exactly once. *The output file accepted_words is to be in the format w1 w2 ... wt Here w1, w2, ..., wt are the words accepted by M_from_file which have length <= n, one per line in the file and in canonical order. That is, word u comes before word v if length(u) < length(v), or if length(u) = length(v) and u comes before v in the lexicographic ordering determined by the presentation order s1 < s2 < ... < sk for the symbols of the alphabet as given in the first line of the input file. *Develop this program following proper methodology, starting with a written plan. Develop the code one method at a time, with readable formatting, meaningful identifier names and illuminating comments. For each method, write the test code for it before writing the code for the method itself. *The submission procedure is described on a separate page which is linked from the "projects" page. Follow it carefully. *A project which does not compile on atlas using version 1.5.0 Java will score 0. Projects which do compile properly will be scored as follows out of 100 (if on time): 30 pts. for good style (meaningful identifier names which indicate class/object by capitlaization, consistent indentation and formatting, comments which make intention clear); 20 pts. for design modularity (generating the goal and playing one move should be separate methods; include testing and debugging methods); 50 pts. for correct operation.