I think that there is a simple mistake, but I really don't know where
package pl.codegym.task.task19.task1903;
/*
Dostosowywanie wielu interfejsów
*/
import java.util.HashMap;
import java.util.Map;
public class Solution {
public static Map<String, String> countries = new HashMap<>(
);
static {
countries.put("UA","Ukraina");
countries.put("US","Stany Zjednoczone");
countries.put("FR","Francja");
}
public static void main(String[] args) {
// String tel = String.valueOf(9912367);
//
// while (tel.length()<10){
// tel = "0"+tel;
// }
//
// tel = "+"+"1"+"("+ tel.substring(0,3)+")" +tel.substring(3,6)+"-"+tel.substring(6,8)+"-"+ tel.substring(8,10);
// System.out.println(tel);
}
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 countries.get( this.data.getCountryCode());
}
@Override
public String getName() {
return this.data.getContactLastName()+", "+this.data.getContactFirstName();
}
@Override
public String getPhoneNumber() {
String tel = String.valueOf(this.data.getPhoneNumber());
while (tel.length()<=10){
tel = "0"+tel;
}
tel = "+"+this.data.getCountryPhoneCode()+"("+ tel.substring(0,3)+")" +tel.substring(3,6)+"-"+tel.substring(6,8)+"-"+ tel.substring(8,10);
return tel;
}
}
public static interface IncomeData {
String getCountryCode(); // Na przykład: US
String getCompany(); // Na przykład: CodeGym Ltd.
String getContactFirstName(); // Na przykład: John
String getContactLastName(); // Na przykład: Smith
int getCountryPhoneCode(); // Na przykład: 1
int getPhoneNumber(); // Na przykład: 991234567
}
public static interface Customer {
String getCompanyName(); // Na przykład: CodeGym Ltd.
String getCountryName(); // Na przykład: Stany Zjednoczone
}
public static interface Contact {
String getName(); // Na przykład: Smith, John
String getPhoneNumber(); // Na przykład: +1(099)123-45-67
}
}