these are the assignment objectives i need help with
Write an interface and two classes which will implements the interface.
Interface - StringVerification
- will have the abstract method defined - boolean verifyInput( String input );
class EmailVerification implements StringVerification
- implement the verifyInput() method in EmailVerification class. The method should validate a user input String, character by character and see the input string has a dot (.) and an at the rate (@) character in it. If any of the condition wrong the verifyInput method will return a false boolean value.
Example of a valid Email id – mail@mymail.com
class PhoneVerification implements StringVerification
- implement the verifyInput() method in PhoneVerification class. The method should validate user input String, character by character and see, the input string is all digits and the phone number has exactly 10 digits. If any of the condition wrong, the verifyInput() method will return a false boolean value.
Example of a valid phone number – 5161112222
here is the code for # 1
public interface StringVerification {
boolean verifyInput( String input );
}
the code that i have for 2
public class EmailVerification implements StringVerification {
private boolean dot;
private boolean atSymbol;
public EmailVerification( )
{
String at = "@";
String period = ".";
dot = false;
atSymbol = false;
}
public boolean verifyInput(String input) {
for ( int i = 0; i < input.length ( ); i++)
{
char c = input.charAt( i );
char at = @ ;
if ( c == at )
return true ;
}
}
}
i have yet to start 3 but i am assuming i use an if statement in a method to make sure that there are 10 digits
i am not sure how to search for specific special characters without using an import