Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.knowledgeblackbelt.students.ideynega.exercises;
- import java.util.List;
- import java.util.LinkedList;
- public class Exercise454 {
- public static void main(String[] args) {
- List<BankAccount> bankAccountList = getBankAccountList();
- List<Customer> customerList = extractCustomerListFromBankAccountList(bankAccountList);
- provideClientService(customerList);
- }
- public static List<BankAccount> getBankAccountList() {
- List<BankAccount> bankAccountList = new LinkedList<BankAccount>();
- bankAccountList.add(new BankAccount("1", 25000.0, new Customer("Robert", "Johnson")));
- bankAccountList.add(new BankAccount("2", 150.0, new Customer("John", "Robertson")));
- return bankAccountList;
- }
- public static List<Customer> extractCustomerListFromBankAccountList(List<BankAccount> bankAccountList) {
- List<Customer> customerList = new LinkedList<Customer>();
- for(BankAccount ba: bankAccountList) {
- customerList.add(ba.customer);
- }
- return customerList;
- }
- public static void provideClientService(List<Customer> customerList) {
- for(Customer currentCustomer: customerList) {
- System.out.println("Customer " + currentCustomer.firstName + " " + currentCustomer.lastName + " has been provided with customer service");
- }
- }
- }
- class BankAccount {
- String number;
- double balance;
- Customer customer;
- BankAccount(String number, double balance, Customer customer) {
- this.number = number;
- this.balance = balance;
- this.customer = customer;
- }
- }
- class Customer {
- String firstName;
- String lastName;
- Customer(String firstName, String lastName) {
- this.firstName = firstName;
- this.lastName = lastName;
- }
- }
Add Comment
Please, Sign In to add comment