Здравствуйте!
По всем условиям из задания проходит, но не принимает. Подскажите, пожалуйста, еще варианты для проверки.
package com.javarush.task.task22.task2212;
/*
Проверка номера телефона
*/
public class Solution {
public static boolean checkTelNumber(String telNumber) {
boolean a=false;
// с + и скобками
if (telNumber.length()==15) {
if (telNumber.matches("\\+\\d+\\(\\d{3}\\)\\d+"))
a=true;
}
// без + со скобками
if (telNumber.length()==12) {
if (telNumber.matches("\\d+\\(\\d{3}\\)\\d+") || telNumber.matches("\\(\\d{3}\\)\\d+"))
a=true;
}
// с + без скобок
if (telNumber.length()==13){
if (telNumber.matches("\\+\\d{12}"))
a=true;
}
// без + без скобок
if (telNumber.length()==10){
if (telNumber.matches("\\d{10}")){
a=true;
}
}
return a;
}
public static void main(String[] args) {
System.out.println(checkTelNumber("(0)501234567"));
}
}