// Inner Class > collect the credit card details from the user // Outer Class > Credit Card Processor // Tuple Class > Securely pass the credit card information thru api // Enumerator > page 47 enum OrderStatus response from api // Scanner Class > user inputs import java.util.Scanner; public class OrderProcessor { // variables private String customerName; // constructor statement public OrderProcessor(String customerName) { // function this.customerName = customerName; // structural } // OrderProcessor() // function to process the customers credit card // base return types > void any boolean others ... public void processOrder() { // CreditCardInfo Class CreditCardInfo creditCardInfo = new CreditCardInfo(); creditCardInfo.inputCreditCardDetails(); // Tuple Class with the User Inputs Tuple result = processOrderWithPayment(creditCardInfo); // Response Code from the API System.out.println("Payment Status: " + result.getFirst()); System.out.println(("Amount Approved: " + result.getSecond())); // getter calls the variable } // processOrder // Tuple immutable tuple private function private Tuple processOrderWithPayment( // Credit Card Info parameter CreditCardInfo creditCardInfo ) { // API response return new Tuple<>(OrderStatus.SUCCESS, 100.00); } // Tuple response // Credit Card Class // inner class of OrderProcess Class // User inputting their credit card information private class CreditCardInfo { // variables private to CreditCardInfo Class private String cardNumber; private String expirationDate; private String cvv; // Get the inputs for the credit card // define a function to call in the application public void inputCreditCardDetails() { Scanner scanner = new Scanner(System.in); System.out.println("Enter Credit Card Number: "); this.cardNumber = scanner.nextLine(); System.out.println("Enter Expiration Date (MM/YY): "); this.expirationDate = scanner.nextLine(); System.out.println("Enter CVV Code: "); this.cvv = scanner.nextLine(); scanner.close(); } // inputCreditCardDetails // getters get the return of the variables in memory public String getCardNumber() { return cardNumber; } // getCardNumber public String getExpirationDate() { return expirationDate; } // expdate public String getCvv() { return cvv; } // cvv } // CreditCardInfo Inner Class // Tuple Structure using an Inner Class // T1 OrderStatus // T2 Double private class Tuple { private T1 first; private T2 second; public Tuple(T1 first, T2 second) { this.first = first; this.second = second; } // constructor // getters public T1 getFirst() { return first; } public T2 getSecond() { return second; } } // Tuple Inner Class // Enumeration for order status private enum OrderStatus { SUCCESS, // UPPERCASE PROVIDERS API RESPONSE FAILURE } // OrderStatus // main() Runtime public static void main(String[] args) { try { Scanner scanner = new Scanner(System.in); System.out.println("Enter Customer Name on Credit Card: "); String customerName = scanner.nextLine(); OrderProcessor orderProcessor = new OrderProcessor(customerName); orderProcessor.processOrder(); // call processOrder() } // try catch (Exception err) { System.out.println("Error occurred: " + err); } // catch finally { System.out.println("Thank you for your order!"); } // finally } // main() } // OrderProcessor Class