package exchange; /** * The interface Currency allows to create objects representing the currency of a * country. Each currency is characterized by its name and contains as data its * exchange rate in euro. This class gives also methods allowing to convert an * amount from the currency to euro and reverse. * * Version for Java1.8, using default methods. */ public interface Currency { public String name(); public double exchangeRateInEuro(); public default double convertInEuro(double amount) { return amount / exchangeRateInEuro(); }; public default double convertFromEuro(double amount) { return amount * exchangeRateInEuro(); }; }