documentation. cleanup. your turn daniel

This commit is contained in:
Walcher 2024-01-10 20:55:57 +01:00
parent 31badb9da5
commit d52ca6e7f8
2 changed files with 23 additions and 19 deletions

View file

@ -3,6 +3,7 @@ package ab1.impl.gruppe10_aigensberger_dworski_walcher;
import ab1.FinalizedStateException;
import ab1.NFA;
import ab1.Transition;
import lombok.Getter;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
@ -17,7 +18,8 @@ public class NFAImpl implements NFA {
private final String initialState;
private final Set<String> acceptingStates;
private Set<Character> alphabet;
@Getter
private final Set<Character> alphabet;
private final Set<Character> completeAlphabet;
private boolean isFinalized;
@ -57,15 +59,10 @@ public class NFAImpl implements NFA {
return this.initialState;
}
public Set<Character> getAlphabet() {
return this.alphabet;
}
/**
* Adds a new transition to the automaton. If the automaton is already finalized, a FinalizedStateException is thrown.
* @param transition The transition to add
* @throws FinalizedStateException
* @throws FinalizedStateException If the automaton is already finalized
*/
@Override
public void addTransition(Transition transition) throws FinalizedStateException {
@ -88,7 +85,7 @@ public class NFAImpl implements NFA {
/**
* Adds all transitions to the automaton. If the automaton is already finalized, a FinalizedStateException is thrown.
* @param transitions The Set of transitions to add
* @throws FinalizedStateException
* @throws FinalizedStateException If the automaton is already finalized
*/
public void addAllTransitions(Set<Transition> transitions) throws FinalizedStateException {
if (this.isFinalized) {
@ -102,7 +99,7 @@ public class NFAImpl implements NFA {
/**
* Adds a new accepting state to the automaton. If the automaton is already finalized, a FinalizedStateException is thrown.
* @param state The state to add as accepting state
* @throws FinalizedStateException
* @throws FinalizedStateException If the automaton is already finalized
*/
@Override
public void addAcceptingState(String state) throws FinalizedStateException {
@ -119,7 +116,7 @@ public class NFAImpl implements NFA {
/**
* Adds all accepting states to the automaton. If the automaton is already finalized, a FinalizedStateException is thrown.
* @param states The Set of states to add as accepting states
* @throws FinalizedStateException
* @throws FinalizedStateException If the automaton is already finalized
*/
public void addAllAcceptingStates(Set<String> states) throws FinalizedStateException {
if (this.isFinalized) {
@ -156,7 +153,7 @@ public class NFAImpl implements NFA {
* Creates a new NFA that is the union of this NFA and the other NFA. If either of the NFAs is not finalized, a FinalizedStateException is thrown.
* @param other The other NFA to union with
* @return The union of this NFA and the other NFA
* @throws FinalizedStateException
* @throws FinalizedStateException If either of the NFAs is not finalized
*/
@Override
public NFA union(NFA other) throws FinalizedStateException {
@ -231,7 +228,7 @@ public class NFAImpl implements NFA {
* Creates a new NFA that is the intersection of this NFA and the other NFA. If either of the NFAs is not finalized, a FinalizedStateException is thrown.
* @param other The other NFA to intersect with
* @return The intersection of this NFA and the other NFA
* @throws FinalizedStateException
* @throws FinalizedStateException If either of the NFAs is not finalized
*/
@Override
public NFA intersection(NFA other) throws FinalizedStateException {
@ -248,7 +245,7 @@ public class NFAImpl implements NFA {
* Creates a new NFA that is the concatenation of this NFA and the other NFA. If either of the NFAs is not finalized, a FinalizedStateException is thrown.
* @param other The other NFA to concatenate with
* @return The concatenation of this NFA and the other NFA
* @throws FinalizedStateException
* @throws FinalizedStateException If either of the NFAs is not finalized
*/
@Override
public NFA concatenation(NFA other) throws FinalizedStateException {
@ -295,7 +292,7 @@ public class NFAImpl implements NFA {
/**
* Creates a new NFA that is the Kleene star of this NFA. If the NFA is not finalized, a FinalizedStateException is thrown.
* @return The Kleene star of this NFA
* @throws FinalizedStateException
* @throws FinalizedStateException If the NFA is not finalized
*/
@Override
public NFA kleeneStar() throws FinalizedStateException {
@ -324,7 +321,7 @@ public class NFAImpl implements NFA {
/**
* Creates a new NFA that is the plus operator of this NFA. If the NFA is not finalized, a FinalizedStateException is thrown.
* @return The plus operator of this NFA
* @throws FinalizedStateException
* @throws FinalizedStateException If the NFA is not finalized
*/
@Override
public NFA plusOperator() throws FinalizedStateException {
@ -353,7 +350,7 @@ public class NFAImpl implements NFA {
/**
* Creates a new NFA that is the complement of this NFA. If the NFA is not finalized, a FinalizedStateException is thrown.
* @return The complement of this NFA
* @throws FinalizedStateException
* @throws FinalizedStateException If the NFA is not finalized
*/
@Override
public NFA complement() throws FinalizedStateException {
@ -597,7 +594,7 @@ public class NFAImpl implements NFA {
* Returns whether the automaton accepts the given word. If the automaton is not finalized, a FinalizedStateException is thrown.
* @param word word to check, can be empty
* @return Whether the automaton accepts the given word
* @throws FinalizedStateException
* @throws FinalizedStateException If the automaton is not finalized
*/
@Override
public boolean acceptsWord(String word) throws FinalizedStateException {