Guest User

Untitled

a guest
Apr 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. public class stateNode
  2. {
  3.     public int stateNumber; //q0, q1, whatever
  4.     public ArrayList paths;
  5.     public boolean isFinal;
  6.     int pathCount;
  7.  
  8.     public void stateNode(int statecount){
  9.         stateNumber = statecount;
  10.         neighbors = new ArrayList();
  11.         isFinal = false;
  12.         pathCount = 0;
  13.     }
  14.    
  15.     public void addPath(autoPath inputPath){
  16.         neighbors.add(inputPath);
  17.         pathCount += 1;
  18.     }
  19.    
  20.     public void addPath(stateNode* destState){
  21.         autoPath(this*, destState);
  22.    
  23.     public void delPath( ){
  24.    
  25.     }
  26.    
  27.     public boolean EndCheck(){
  28.         return isFinal;
  29.     }
  30.    
  31.     public stateNode* Traverse(char input){
  32.         for(int i = 0; i < paths.size(); i++){
  33.             if (paths[i].checkInput(input)){
  34.                 return paths[i].destination;
  35.             }
  36.         }
  37.         return paths[0].source; //I dunno if this works. I want it to return the original stateNode* it was at.
  38.     }
  39.                
  40.    
  41.    
  42. }
  43. //Class for a path.
  44. public class autoPath
  45. {
  46.     public stateNode* source;
  47.     public stateNode* destination;
  48.     public ArrayList inputs;
  49.    
  50.     public void autoPath(stateNode* src, stateNode* dst){
  51.         source = src;
  52.         destination = dst;
  53.     }
  54.    
  55.     public void setChars(ArrayList inputChars){
  56.         inputs = inputChars;
  57.     }
  58.    
  59.     public boolean checkInput(char input){
  60.         for(int i = 0; i < inputs.size(); i++){
  61.             if(inputs[i] == input){
  62.                 return true;
  63.                 }
  64.             }
  65.         return false;
  66.     }
  67. }
Add Comment
Please, Sign In to add comment