java - Can I improve this Pig-Latin converter? -
I am spanking new in Java and I have made it a little translator for Pig Latin.
package stringnipulation; Public Class Piglatin Controller {Public String Convert (String Word) {Ent condition = 0; If (i.e.V.V.Lat (0)) {for (int i = 0; i and lt; word lilayat (); i ++) {if (i.evw.well (word chat (i)) {status = I; break; }} String first = words bstring (position, word.length ()); String II = Word Springing (0, position) + "AE"; First + second; } And {return word + "route"; }} Public Boolean isvovell (four c) {if (c == 'a') returns true; And if (C == 'E') is true; Otherwise if (C == 'I') is true; Otherwise if (C == 'O') is true; And if (C == 'U') is true; Second false return; }}
Is there any improvement that I can do?
Is there any Java Java tricks that are in the latest Java version, maybe I do not know? I came from C # background.
Thank you!
I want to rewrite isVowel (char ch)
as follows :
return "aeou" .indexOf (ch)! = -1;
And I will write the following instead:
// string first = words bstring (position, word. Length); String first = word Springing (position);
I can also change the name of the method names to follow the coding convention.
And of course, being me, I use regex instead of substring
and for
loop.
System.out.println ("string" .replaceAll ("([aiiou] +) (. *)", "$ 2 $ 1ay")); // ingstray
Comments
Post a Comment