Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. public class SkillBuilder5
  2. {
  3. // define your constants after this comment
  4. private final static int No_t = 0;
  5. private final static int One_t = 1;
  6. private final static int Yes_t_y = 2;
  7. // define your constants before this comment
  8.  
  9. public static String findTYPattern(String s)
  10. {
  11. // add your code here.
  12. String str = " ";
  13. boolean isDone = false;
  14. int index = 0;
  15. int currentState = 0;
  16.  
  17. while((index < s.length) && (!(isDone))){
  18. char ch = s.charAtIndex(index);
  19. index++;
  20. switch(currentState)
  21. {
  22. case(No_t):
  23. if(ch.toLowerCase(ch) == "t")
  24. {
  25. str = str + ch;
  26. currentState = One_t;
  27. }break;
  28. case(One_t):
  29. if(ch.toLowerCase(ch) == "y")
  30. {
  31. currentState = Yes_t_y;
  32. }
  33. str = str+ch;
  34. break;
  35. case(Yes_t_y):
  36. isDone = true;
  37. break;
  38.  
  39. }
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement