вроде все как надо, но...
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 class IncomeDataAdapter implements Customer, Contact {
private IncomeData data;
public IncomeDataAdapter(IncomeData data) {
this.data = data;
}
public String getCompanyName() {
return data.getCompany();
}
public String getCountryName() {
return Solution.countries.get(data.getCountryCode());
}
public String getName() {
return data.getContactLastName() + ", " + data.getContactFirstName();
}
public String getPhoneNumber() {
String[] result = new String[10];
int phoneNumber = data.getPhoneNumber();
Integer count = 0;
Integer number;
while(count != 10) {
number = phoneNumber % 10;
result[9-count] = number.toString();
phoneNumber = phoneNumber / 10;
count++;
}
return "+" + data.getCountryCode() + "(" + result[0] + result[1] + result[2] + ")" + result[3] + result[4] + result[5] + "-" + result[6] + result[7] + "-" + result[8] + result[9];
}
}
public static interface IncomeData {
String getCountryCode(); //For example: UA
String getCompany(); //For example: JavaRush Ltd.
String getContactFirstName(); //For example: Ivan
String getContactLastName(); //For example: Ivanov
int getCountryPhoneCode(); //For example: 38
int getPhoneNumber(); //For example: 501234567
}
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
}
}