//I know that, when I come to you, I will come in the fullness of the blessing of the Good News of Christ. (Romans 15:29)
package com.javarush.task.task19.task1903;
/*
ÐдапÑаÑÐ¸Ñ Ð½ÐµÑколÑкиÑ
инÑеÑÑейÑов
*/
import java.util.HashMap;
import java.util.Map;
public class Solution {
public static Map countries = new HashMap();
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 incomeData) {
this.data = incomeData;
}
@Override
public String getCompanyName() {
return data.getCompany();
}
@Override
public String getCountryName() {
return countries.get(data.getCountryCode());
}
@Override
public String getName() {
return String.format("%s, %s", data.getContactLastName(), data.getContactFirstName());
}
@Override
public String getPhoneNumber() {
String phone = String.format("%010d", data.getPhoneNumber());
String result = "+" + data.getCountryPhoneCode() + "(" + phone.substring(0,3) + ")" +
phone.substring(3,6) + "-" + phone.substring(6,8) + "-" + phone.substring(8);
return result ;
}
}
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
}
}
/*
ÐдапÑаÑÐ¸Ñ Ð½ÐµÑколÑкиÑ
инÑеÑÑейÑов
ÐдапÑиÑÑй IncomeData к Customer и Contact.
ÐлаÑÑом-адапÑеÑом ÑвлÑеÑÑÑ IncomeDataAdapter.
ÐниÑиализиÑÑйÑе countries пеÑед наÑалом вÑÐ¿Ð¾Ð»Ð½ÐµÐ½Ð¸Ñ Ð¿ÑогÑаммÑ. СооÑвеÑÑÑвие кода ÑÑÑÐ°Ð½Ñ Ð¸ названиÑ:
UA Ukraine
RU Russia
CA Canada
ÐополниÑÑ ÑелеÑоннÑй Ð½Ð¾Ð¼ÐµÑ Ð½ÑлÑми до 10 ÑиÑÑ Ð¿Ñи необÑ
одимоÑÑи (ÑмоÑÑи пÑимеÑÑ).
ÐбÑаÑиÑе внимание на ÑоÑÐ¼Ð°Ñ Ð²Ñвода Ñамилии и имени Ñеловека.
ТÑебованиÑ:
1.âÐлаÑÑ Solution должен ÑодеÑжаÑÑ public static поле countries Ñипа Map.
2.âÐ ÑÑаÑиÑеÑком блоке клаÑÑа Solution иниÑиализиÑÑй поле countries ÑеÑÑовÑми даннÑми ÑоглаÑно заданиÑ.
3.âÐлаÑÑ IncomeDataAdapter должен ÑеализовÑваÑÑ Ð¸Ð½ÑеÑÑейÑÑ Customer и Contact.
4.âÐлаÑÑ IncomeDataAdapter должен ÑодеÑжаÑÑ Ð¿ÑиваÑное поле data Ñипа IncomeData.
5.âÐлаÑÑ IncomeDataAdapter должен ÑодеÑжаÑÑ ÐºÐ¾Ð½ÑÑÑÑкÑÐ¾Ñ Ñ Ð¿Ð°ÑамеÑÑом IncomeData.
6.âРклаÑÑе IncomeDataAdapter ÑеализÑй меÑÐ¾Ð´Ñ Ð¸Ð½ÑеÑÑейÑов Customer и Contact иÑполÑзÑÑ Ð¿Ð¾Ð´Ñказки в виде комменÑаÑиев в инÑеÑÑейÑаÑ
.
package com.javarush.task.task19.task1903;
*
ÐдапÑаÑÐ¸Ñ Ð½ÐµÑколÑкиÑ
инÑеÑÑейÑов
*
import java.util.HashMap;
import java.util.Map;
public class Solution {
public static Map countries = new HashMap();
public static void main(String[] args) {
}
public static class IncomeDataAdapter {
}
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
}
}
*/