just some fancy shit added

This commit is contained in:
Ghost_Element 2024-01-10 15:49:49 +01:00
parent b6ab5bdf72
commit c81659c1f9
3 changed files with 22 additions and 16 deletions

View file

@ -6,8 +6,6 @@ import ab1.NFAFactory;
public class NFAFactoryImpl implements NFAFactory {
@Override
public NFA buildNFA(String startState) {
NFA nfa = new NFAImpl(startState);
return nfa;
return new NFAImpl(startState);
}
}

View file

@ -16,7 +16,7 @@ public class NFAImpl implements NFA {
private Set<Character> alphabet;
private Set<Character> completeAlphabet;
private final Set<Character> completeAlphabet;
private boolean isFinalized;
public NFAImpl(String startState) {
@ -210,8 +210,7 @@ public class NFAImpl implements NFA {
NFA newNFA_A = this.complement();
NFA newNFA_B = other.complement();
NFA unionNFA = newNFA_A.union(newNFA_B);
NFA result = unionNFA.complement();
return result;
return unionNFA.complement();
}
@Override
@ -447,7 +446,7 @@ public class NFAImpl implements NFA {
// need newLetter
for(int i=letters.indexOf(readSymbol)+1;i<letters.size();i++){
Character newLetter = letters.get(i);
String newState = checkForNewLetter(path, transitions, letters, newLetter);
String newState = checkForNewLetter(path, transitions, newLetter);
//more than 1 transition for new letter?
if(newState!=null){
//check given state
@ -483,10 +482,10 @@ public class NFAImpl implements NFA {
/**
* !Does not check the new state added
* @return state if a tostate for the newletter is found and deletes the old Tuple
* @return null if with the newletter there is no transition further
* @return -state if a tostate for the newletter is found and deletes the old Tuple
* -null if with the newletter there is no transition further
*/
private String checkForNewLetter(List<Tuple> path, List<Transition> transitions, List<Character> letters, Character letter){
private String checkForNewLetter(List<Tuple> path, List<Transition> transitions, Character letter){
String fromState = path.get(path.size()-2).getElement_2();
for(Transition transition : transitions){
if (transition.fromState().equals(fromState) && transition.readSymbol().equals(letter)) {