/* * Copyright (c) 2015 Camil Staps */ package com.camilstaps.webshop.payment; import java.util.Scanner; /** * * @author camilstaps */ public class IDeal implements PaymentMethod { private String bank, accountNr, pincode; private Scanner sc = new Scanner(System.in); public IDeal() { } public IDeal(String bank, String accountNr, String pincode) { this.bank = bank; this.accountNr = accountNr; this.pincode = pincode; } private void ensureBank() { if (bank != null) return; System.out.print("Bank: "); bank = sc.nextLine(); } private void ensureAccountNr() { if (accountNr != null) return; System.out.print("Account nr: "); accountNr = sc.nextLine(); } private void ensurePincode() { if (pincode != null) return; System.out.print("Pincode: "); pincode = sc.nextLine(); } @Override public boolean pay(double amount) { ensureBank(); ensureAccountNr(); ensurePincode(); System.out.println("€" + amount + " paid with iDeal: \n" + bank + " : " + accountNr + " (" + pincode + ")"); return true; } }