finiteAutomata
Class NFAMenu

java.lang.Object
  extended by finiteAutomata.NFAMenu

public class NFAMenu
extends java.lang.Object

Menu and query methods for the NFA class.

Version:
Fall 2007
Author:
Barbara Wahl

Constructor Summary
NFAMenu()
           
 
Method Summary
protected static void addEpsilonDialog(NFA nfa)
          Queries user regarding which epsilon transition to add.
protected static void addTransitionDialog(NFA nfa)
          Queries user regarding which symbol-consuming transition to add.
protected static void changeTransition(NFA nfa, int n)
          Takes action based on provided transition change choice code.
protected static int changeTransitionDialog()
          Queries user regarding desired transition change.
protected static int constructorMenu()
          Displays constructor menu options and prompts user to choose an action.
protected static boolean constructorMenuHandler(NFA nfa, int choice)
          Takes action based on the provided constructor menu choice code.
static void main(java.lang.String[] args)
           
protected static void queryAlphabet(NFA nfa)
          Queries user to obtain alphabet of input symbols.
protected static void queryFinal(NFA nfa)
          Queries user to determine which states are final.
protected static void queryNumStates(NFA nfa)
          Prints constructor menu heading, and queries user until valid (positive) number of states is obtained.
protected static boolean queryPredefined()
          Asks user if they want to use a pre-defined NFA.
protected static void removeEpsilonDialog(NFA nfa)
          Queries user regarding which epsilon transition to remove.
protected static void removeTransitionDialog(NFA nfa)
          Queries user regarding which symbol-consuming transition to remove.
protected static int runMenu()
          Displays run menu options and prompts user to make a choice of action.
protected static boolean runMenuHandler(NFA nfa, int choice)
          Takes action based on the provided run menu choice code.
protected static void testingDialog(NFA nfa)
          Allows the user to repeatedly test strings on an NFA.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NFAMenu

public NFAMenu()
Method Detail

queryPredefined

protected static boolean queryPredefined()
Asks user if they want to use a pre-defined NFA.

Returns:
true iff user response begins with 'Y' or 'y'

queryNumStates

protected static void queryNumStates(NFA nfa)
Prints constructor menu heading, and queries user until valid (positive) number of states is obtained.

Parameters:
nfa - the NFA being operated on
Postcondition:
nfa.numStates is initialized to a positive integer value

queryAlphabet

protected static void queryAlphabet(NFA nfa)
Queries user to obtain alphabet of input symbols.

Parameters:
nfa - the NFA being operated on
Postcondition:
Alphabet of the specified NFA is initialized according to user response

queryFinal

protected static void queryFinal(NFA nfa)
Queries user to determine which states are final.

Parameters:
nfa - the NFA being operated on
Postcondition:
isFinal array is initialized according to user responses

constructorMenu

protected static int constructorMenu()
Displays constructor menu options and prompts user to choose an action.

Returns:
valid choice number (1 thru 6)

constructorMenuHandler

protected static boolean constructorMenuHandler(NFA nfa,
                                                int choice)
Takes action based on the provided constructor menu choice code.

Parameters:
nfa - the NFA being operated on
choice - constructor menu choice code
Returns:
true iff user is done with menu options
Precondition:
1 <= choice <= 6

runMenu

protected static int runMenu()
Displays run menu options and prompts user to make a choice of action.

Returns:
integer choice code (1 through 9)

runMenuHandler

protected static boolean runMenuHandler(NFA nfa,
                                        int choice)
Takes action based on the provided run menu choice code.

Parameters:
nfa - the NFA being operated on
choice - run menu choice code
Returns:
true iff user is done with menu options
Precondition:
1 <= choice <= 9

changeTransitionDialog

protected static int changeTransitionDialog()
Queries user regarding desired transition change.

Returns:
transition change choice code (1 through 4)

changeTransition

protected static void changeTransition(NFA nfa,
                                       int n)
Takes action based on provided transition change choice code.

Parameters:
nfa - the NFA being operated on
n - transition change choice code
Postcondition:
makes changes to transition array and re-calculates the equivalent DFA

removeEpsilonDialog

protected static void removeEpsilonDialog(NFA nfa)
Queries user regarding which epsilon transition to remove.

Parameters:
nfa - the NFA being operated on
Postcondition:
if user provides valid state numbers i and j, epsilon[i][j] is set to false and the equivalent DFA is re-calculated

removeTransitionDialog

protected static void removeTransitionDialog(NFA nfa)
Queries user regarding which symbol-consuming transition to remove.

Parameters:
nfa - the NFA being operated on
Postcondition:
if user provides valid state numbers i and j, and valid symbol s, the transition array is changed accordingly and the equivalent DFA is re-calculated

addEpsilonDialog

protected static void addEpsilonDialog(NFA nfa)
Queries user regarding which epsilon transition to add.

Parameters:
nfa - the NFA being operated on
Postcondition:
if user provides valid state numbers i and j, epsilon[i][j] is set to true and the equivalent DFA is re-calculated

addTransitionDialog

protected static void addTransitionDialog(NFA nfa)
Queries user regarding which symbol-consuming transition to add.

Parameters:
nfa - the NFA being operated on
Postcondition:
if user provides valid state numbers i and j, and valid symbol s, the transition array is changed accordingly and the equivalent DFA is re-calculated

testingDialog

protected static void testingDialog(NFA nfa)
Allows the user to repeatedly test strings on an NFA.

Parameters:
nfa - the NFA being operated on
Postcondition:
Each input string is echoed back to the console with a report of the string's length and whether or not it is accepted

main

public static void main(java.lang.String[] args)
Parameters:
args -