private void buttonB_Click(object sender, EventArgs e) { myAutomaton.actualLetter = "b"; string myNextState = myAutomaton.AFD(myAutomaton.actualState, myAutomaton.actualLetter, myAutomaton.finalStates); // When reaches the acceptation state for (int i = 0; i < myAutomaton.finalStates.Length; i++) { if (myNextState == myAutomaton.finalStates[i]) { AutomatonLog.AppendText("\n" + "d(" + myAutomaton.actualState + "," + myAutomaton.actualLetter + ") = " + myNextState + " Estado de aceptación"); myAutomaton.actualState = myNextState; AutomatonStrings.AppendText(myAutomaton.actualLetter); return; } } // When reaches the NO acceptation state for (int i = 0; i < myAutomaton.states.Length; i++) { if (myNextState == myAutomaton.states[i]) { AutomatonLog.AppendText("\n" + "d(" + myAutomaton.actualState + "," + myAutomaton.actualLetter + ") = " + myNextState + " Estado de NO aceptación"); myAutomaton.actualState = myNextState; AutomatonStrings.AppendText(myAutomaton.actualLetter); return; } } // When there is not an state AutomatonLog.AppendText("\nNo hay estado"); myAutomaton.actualState = myNextState; AutomatonStrings.AppendText(""); }
public void start(string[] args) { // To initialize the automaton object myAutomaton.states = new string[3]; myAutomaton.states[0] = "Q0"; myAutomaton.states[1] = "Q1"; myAutomaton.states[2] = "Q2"; myAutomaton.alphabet = new string[2]; myAutomaton.alphabet[0] = "a"; myAutomaton.alphabet[1] = "b"; myAutomaton.transitionFunction = new string[3, 2]; myAutomaton.transitionFunction[0, 0] = textBoxQ0a.Text; myAutomaton.transitionFunction[0, 1] = textBoxQ0b.Text; myAutomaton.transitionFunction[1, 0] = textBoxQ1a.Text; myAutomaton.transitionFunction[1, 1] = textBoxQ1b.Text; myAutomaton.transitionFunction[2, 0] = textBoxQ2a.Text; myAutomaton.transitionFunction[2, 1] = textBoxQ2b.Text; myAutomaton.initialState = "Q0"; myAutomaton.finalStates = new string[1]; myAutomaton.finalStates[0] = "Q1"; myAutomaton.actualState = "Q0"; myAutomaton.actualLetter = "a"; // To clear the text AutomatonLog.Clear(); AutomatonLog.AppendText("\n" + "Q0" + " Estado inicial"); AutomatonStrings.Clear(); }
//******************************************************** //******************************************************** // Automaton AFD private void buttonReset_Click(object sender, EventArgs e) { // To initialize the automaton object myAutomaton.states = new string[3]; myAutomaton.states[0] = "Q0"; myAutomaton.states[1] = "Q1"; myAutomaton.states[2] = "Q2"; myAutomaton.alphabet = new string[2]; myAutomaton.alphabet[0] = "a"; myAutomaton.alphabet[1] = "b"; myAutomaton.transitionFunction = new string[3, 2]; myAutomaton.transitionFunction[0, 0] = textBoxQ0a.Text; myAutomaton.transitionFunction[0, 1] = textBoxQ0b.Text; myAutomaton.transitionFunction[1, 0] = textBoxQ1a.Text; myAutomaton.transitionFunction[1, 1] = textBoxQ1b.Text; myAutomaton.transitionFunction[2, 0] = textBoxQ2a.Text; myAutomaton.transitionFunction[2, 1] = textBoxQ2b.Text; myAutomaton.initialState = "Q0"; myAutomaton.finalStates = new string[1]; myAutomaton.finalStates[0] = "Q1"; myAutomaton.actualState = "Q0"; myAutomaton.actualLetter = "a"; // To clear the text AutomatonLog.Clear(); AutomatonLog.AppendText("********Think Outside the BOX *********" + "\n" + "Q0" + " Estado inicial"); AutomatonStrings.Clear(); }