What is wrong?
package com.codegym.task.task19.task1905;
import java.util.HashMap;
import java.util.Map;
/*
Reinforce the adapter
*/
public class Solution {
public static Map<String,String> countries = new HashMap<>();
static {
countries.put("UA", "Ukraine");
countries.put("US", "United States");
countries.put("FR", "France");
}
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 country = "";
for (Map.Entry<String, String> mapa:
countries.entrySet()) {
String b = mapa.getValue();
String a = mapa.getKey();
if(b.equals(customer.getCountryName())){
country = a;
break;
}
}
return country;
}
@Override
public String getCompany() {
return customer.getCompanyName();
}
@Override
public String getContactFirstName() {
String name = contact.getName();
String fn = name.substring(name.indexOf(" ")+1);
return fn;
}
@Override
public String getContactLastName() {
String namee = contact.getName();
String ln = namee.substring(0, namee.indexOf(" ")-1);
return ln;
}
@Override
public String getDialString() {
String s = contact.getPhoneNumber();
String first = s.substring(s.length()-4, s.length());
String second = s.substring(s.length()-9, s.length()-5);
String third = s.substring(s.indexOf("(")+1, s.indexOf(")"));
String fourth = s.substring(s.indexOf("+")+1, s.indexOf("("));
String good = fourth + third + second + first;
return "callto://" + good;
}
}
public static interface RowItem {
String getCountryCode(); // For example: US
String getCompany(); // For example: CodeGym Ltd.
String getContactFirstName(); // For example: John
String getContactLastName(); // For example: Peterson
String getDialString(); // For example: callto://+11112223333
}
public static interface Customer {
String getCompanyName(); // For example: CodeGym Ltd.
String getCountryName(); // For example: United States
}
public static interface Contact {
String getName(); // For example: Peterson, John
String getPhoneNumber(); // For example: +1(111)222-3333, +3(805)0123-4567, +380(50)123-4567, etc.
}
}