Advertisement
natalierey

Untitled

Feb 20th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. package predictive;
  2. import java.util.Observable;
  3. import java.util.Set;
  4.  
  5. public class Model extends Observable
  6. {
  7. TreeDictionary dictionary;
  8. String currentSignature = "";
  9. Set<String> matching;
  10. String[] arrayMatching;
  11. int i=0;
  12.  
  13. public Model()
  14. {
  15. this.dictionary = new TreeDictionary("words");
  16. }
  17.  
  18. public String[] getCurrentWords(String currentSig)
  19. {
  20. matching = dictionary.signatureToWords(currentSig);
  21. String[] arrayMatching = matching.toArray(new String[matching.size()]);
  22. return arrayMatching;
  23. }
  24.  
  25. public String getCurrentSignature()
  26. {
  27. return currentSignature;
  28. }
  29.  
  30. public void setCurrentSignature(String newSignature)
  31. {
  32. currentSignature = newSignature;
  33. setChanged();
  34. notifyObservers(newSignature);
  35. }
  36.  
  37. public int getI()
  38. {
  39. return i;
  40. }
  41.  
  42. public void setI(int i)
  43. {
  44. this.i = i;
  45. }
  46.  
  47. public String getNextWord()
  48. {
  49. i+=1;
  50. setChanged();
  51. notifyObservers();
  52. return arrayMatching[i];
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement