Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SkillBuilder5
- {
- // define your constants after this comment
- private final static int No_t = 0;
- private final static int One_t = 1;
- private final static int Yes_t_y = 2;
- // define your constants before this comment
- public static String findTYPattern(String s)
- {
- // add your code here.
- String str = " ";
- boolean isDone = false;
- int index = 0;
- int currentState = 0;
- while((index < s.length) && (!(isDone))){
- char ch = s.charAtIndex(index);
- index++;
- switch(currentState)
- {
- case(No_t):
- if(ch.toLowerCase(ch) == "t")
- {
- str = str + ch;
- currentState = One_t;
- }break;
- case(One_t):
- if(ch.toLowerCase(ch) == "y")
- {
- currentState = Yes_t_y;
- }
- str = str+ch;
- break;
- case(Yes_t_y):
- isDone = true;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement