Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * SkillBuilder5 is a class for completing the Skill
- * Builder 5 assignment in Java.
- *
- * @author <You>
- * @version 1.0
- */
- 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 = "Hello, my name is Tom Brady and I am thirsty";
- boolean isDone = false;
- int index = 0;
- int currentState = 0;
- while((index < s.length()) && (!(isDone))){
- char ch = s.charAt(index);
- index++;
- switch(currentState)
- {
- case(No_t):
- if(Character.toLowerCase(ch) == 't')
- {
- str = str + ch;
- currentState = One_t;
- }break;
- case(One_t):
- if(Character.toLowerCase(ch) == 'y')
- {
- currentState = Yes_t_y;
- }
- str = str+ch;
- break;
- case(Yes_t_y):
- isDone = true;
- break;
- }
- }
- return str;}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement