Hi,
Following your advices, I've made the changes to my program accordingly. But I still have errors that I don't know how to fix.
PersondDB code:
//String email_String = Validator.getString(sc, "Enter Email Address: ");
System.out.println("Enter Email Address: ");
String email = sc.next();
int strLength = email.length();
System.out.println("" + strLength);
Validator.validateEmail(email, strLength);
c.setEmail(email);
Validator code:
public boolean validateEmail(String emailValid, int strLength)
{
isvalid = false;
while ((emailValid[0].equals('@'))
|| (emailValid[emailValid - 1].equals('@')))
{
System.out.println("ERROR! you cannot enter @ at the beginning or the end of your email address.\n");
}
if (int index = 1, index < strLength-1, index++)
{
if (emailValid[index].equals("@"))
{
return true;
}
else
{
if (index == strLength-2)
{
return false;
}
}
}
return isvalid;
}
And this is the list of errors I have:
.\Validator.java:23: '.class' expected
if (int index = 1, index < strLength-1, index++)
^
.\Validator.java:38: ')' expected
return isvalid;
^
X:\java CS170\Lab 2b\PersonDB.java:33: non-static method validateEmail(java.lang.String,int) cannot be referenced from a static context
Validator.validateEmail(email, strLength);
^
.\Validator.java:15: cannot find symbol
symbol : variable isvalid
location: class Validator
isvalid = false;
^
.\Validator.java:17: array required, but java.lang.String found
while ((emailValid[0].equals('@'))
^
.\Validator.java:18: operator - cannot be applied to java.lang.String,int
|| (emailValid[emailValid - 1].equals('@')))
^
.\Validator.java:18: array required, but java.lang.String found
|| (emailValid[emailValid - 1].equals('@')))
^
.\Validator.java:23: unexpected type
required: value
found : class
if (int index = 1, index < strLength-1, index++)
^
8 errors