package com.mybank.domain;

import java.util.ArrayList;
import java.util.List;

public class Bank {

//	private static Customer[] customers;
	private static List<Customer> customers;
	private static int numberOfCustomers;

	public Bank() {

	}

	// static initializer - used to initialize static fields
	static {
//		customers = new Customer[10];
		customers = new ArrayList<Customer>();
		numberOfCustomers = 0;
	}

	public static void addCustomer(String f, String l) {
//		customers[numberOfCustomers++] = new Customer(f, l);
		customers.add(new Customer(f, l));
		numberOfCustomers++;
	}

	public static int getNumOfCustomers() {
		return numberOfCustomers;
	}

	public static Customer getCustomer(int index) {
		// check if index is valid
		if (index >= 0) {
			// check if customer is existed
			if (customers.get(index) != null) {
				return customers.get(index);
			}
//			if (customers[index] != null) {
//				return customers[index];
//			}
		}
		return null;
	}
}
