Adapter
package com.dp.Adapter;
public interface ILocationLocator{ public abstract String getCurrentLocation(); } |
package com.dp.Adapter;
import java.util.Locale; public class CountryInformer{ public String getCountryName(){ return Locale.getDefault().getDisplayCountry(); } } |
package com.dp.Adapter;
public class LocationAdapter extends CountryInformer implements ILocationLocator{ public String getCurrentLocation(){ return super.getCountryName(); } } |
package com.dp.Adapter;
public class LocationAdapterTest{ public static void main(String[] argv){ ILocationLocator locator = new LocationAdapter(); System.out.println("Current Location of user is: " +locator.getCurrentLocation()); } } |