// Adapter public class XPayAdapter implements PaymentProcessor { private XPayGateway xPayGateway; private static double euro2usd; // Ισοτιμία public XPayAdapter(XPayGateway xPayGateway, double conversion_rate) { this.xPayGateway = xPayGateway; euro2usd = conversion_rate; } @Override public void processPayment(double amountInEuro) { // 1. Μετατροπή του ποσού από Ευρώ σε Δολλάρια double amountInUSD = amountInEuro * euro2usd; System.out.printf("Adapter: Μετατροπή %.2f€ σε %.2f$%n", amountInEuro, amountInUSD); // 2. Κλήση της μεθόδου του Adaptee xPayGateway.chargeInUSD(amountInUSD); } }