Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Hawaii{
- private String word;//instance variable
- public Hawaii( String w ){//constructor
- word = w;
- }
- //method to check if hawaii word is valid
- public boolean isValid(){
- String legalCharacters = "aeioupkhlmnw '";
- for( int i = 0; i < word.length(); i++ ){
- String letter = word.substring(i, i+1);
- if( legalCharacters.indexOf( letter ) == -1 ) return false;
- }
- return true;
- }
- //method to determine if pair is special
- private boolean isSpecialPair(String pair){
- String[] pairs = {"ai", "ae", "ao", "au", "ei", "eu", "iu", "oi", "ou", "ui"};
- for(int i = 0; i < pairs.length; i++){
- if( pair.equals( pairs[i] ) ) return true;
- }
- return false;
- }
- //method to return the pronunciation of the special pair
- private String pronouncePair(String pair){
- String[] pairs = {"ai", "ae", "ao", "au", "ei", "eu", "iu", "oi", "ou", "ui"};
- String[] pronounce = {"eye", "eye", "ow", "ow", "ay", "eh-oo", "ew", "oy", "ow", "ooey"};
- for(int i = 0; i < pairs.length; i++){
- if( pair.equals( pairs[i] ) ) return pronounce[i];
- }
- return "";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement