I've been trying to return a line of code using a substring, but everytime I try to compile I get the error "cannot find symbol - method findFirstVowel()" It appears in the final line of code. Why does this not work? findFirstVowel should be returning an integer right? And this method doesn't require an input either - so the parameter should be (0, the value of findFirstVowel). Does anyone know how to fix this? Thanks!
public class words
{
private String w;
/**
* Default Constructor for objects of class words
*/
public words()
{
// initialise instance variables
w="";
}
/**
* Assignment constructor
*/
public words(String assignment)
{
w=assignment;
}
/**
* Copy constructor
*/
public words(words two)
{
w=two.w;
}
/**
* Pre: 0<=i<length( )
* returns true if the character at location i is a vowel (‘a’, ‘e’, ‘i', ‘o’, ‘u’ only), false if not
*/
public boolean isVowel(int i)
{
char vowel = w.charAt(i);
return vowel == 'a' || vowel == 'e' || vowel == 'i' || vowel == 'o' || vowel == 'u';
}
/**
* determines whether the first vowel in the String is at location 0, 1, 2, or 3 (don’t worry about exceptions)
*/
public int findFirstVowel()
{
if (isVowel(0))
return 0;
else if (isVowel(1))
return 1;
else if (isVowel(2))
return 2;
else if (isVowel(3))
return 3;
else
return -1;
}
/**
* returns the Pig-Latin version of the String
*/
public String pigify()
{
return w.substring(w.findFirstVowel()) + w.substring(0,w.findFirstVowel()) + "ay";
}