Подскажите, пожалуйста, где ошибка не проходит только по пункту "метод getCountryCode должен вернуть страну из countries"
package com.javarush.task.task19.task1905;
import java.lang.reflect.Array;
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 class DataAdapter implements RowItem {
private Customer customer;
private Contact contact;
public DataAdapter(Customer customer, Contact contact) {
this.contact = contact;
this.customer = customer;
}
@Override
public String getCountryCode() {
String key = null;
for (Map.Entry<String, String> pair : countries.entrySet()) {
if (pair.getValue().equals(this.customer.getCompanyName())) {
key = pair.getKey();
}
}
return key;
}
@Override
public String getCompany() {
return this.customer.getCompanyName();
}
@Override
public String getContactFirstName() {
String[] name = this.contact.getName().split(", ");
return name[1];
}
@Override
public String getContactLastName() {
String[] name = this.contact.getName().split(", ");
return name[0];
}
@Override
public String getDialString() {
String phoneNumber = this.contact.getPhoneNumber();
char[] phone = phoneNumber.toCharArray();
String newPhone = null;
for (int i = 0; i < phone.length; i++) {
if (phone[i] == '(' || phone[i] == ')' || phone[i] == '-') {
i++;
}
newPhone = newPhone + phone[i];
}
String phoneContact = newPhone.substring(0, 3) + String.format("%10s", newPhone.substring(3, 13));
return phoneContact;
}
}
public static interface RowItem {
String getCountryCode(); //For example: UA
String getCompany(); //For example: JavaRush Ltd.
String getContactFirstName(); //For example: Ivan
String getContactLastName(); //For example: Ivanov
String getDialString(); //For example: callto://+380501234567
}
public static interface Customer {
String getCompanyName(); //For example: JavaRush Ltd.
String getCountryName(); //For example: Ukraine
}
public static interface Contact {
String getName(); //For example: Ivanov, Ivan
String getPhoneNumber(); //For example: +38(050)123-45-67 or +3(805)0123-4567 or +380(50)123-4567 or ...
}
}