валик ругается на формат номера телефона
в 67 строке пробел после + уже убрал, не помогло
package com.javarush.task.task19.task1903;
/*
Адаптация нескольких интерфейсов
*/
import java.util.HashMap;
import java.util.Map;
public class Solution {
public static Map<String, String> countries = new HashMap<String, String>();
static {
countries.put("UA","Ukraine");
countries.put("RU", "Russia");
countries.put("CA", "Canada");
}
public static void main(String[] args) {
}
// public static String getNumber(String s){
// int length = 10;
// int diff = 0;
// String z = "0";
// String result ="";
// if ((diff = length - s.length())>0){
// for (int i = 0; i <diff-1 ; i++) {
// z+=z;
// }
// result = z+s;
// }return "("+result.substring(0,3)+")"+result.substring(3,6)+"-"+result.substring(6,8)+"-"+result.substring(8,10);
// }
public static class IncomeDataAdapter implements Customer, Contact{
private IncomeData data;
public IncomeDataAdapter(IncomeData incomeData) {
this.data = incomeData;
}
@Override
public String getCompanyName() {
return this.data.getCompany();
}
@Override
public String getCountryName() {
return Solution.countries.get(this.data.getCountryCode());
}
@Override
public String getName() {
return this.data.getContactLastName()+", "+ this.data.getContactFirstName();
}
@Override
public String getPhoneNumber() {
int length = 10;
int diff = 0;
String s = String.valueOf(this.data.getPhoneNumber());
if ((diff = length - s.length())>0){
for (int i = 0; i <diff-1 ; i++) {
s="0"+s;
}
}return "+"+this.data.getCountryPhoneCode()+"("+s.substring(0,3)+")"+s.substring(3,6)+"-"+s.substring(6,8)+"-"+s.substring(8,10);
}
}
public static interface IncomeData {
String getCountryCode(); //example UA
String getCompany(); //example JavaRush Ltd.
String getContactFirstName(); //example Ivan
String getContactLastName(); //example Ivanov
int getCountryPhoneCode(); //example 38
int getPhoneNumber(); //example 501234567
}
public static interface Customer {
String getCompanyName(); //example JavaRush Ltd.
String getCountryName(); //example Ukraine
}
public static interface Contact {
String getName(); //example Ivanov, Ivan
String getPhoneNumber(); //example +38(050)123-45-67
}
}