package com.accenture.multibank.factory;

import com.accenture.multibank.accounts.AccountModifiable;
import com.accenture.multibank.accounts.AccountType;
import com.accenture.multibank.accounts.CreditAccount;
import com.accenture.multibank.accounts.SavingAccount;
import com.accenture.multibank.exceptions.OperationNotSupportedException;
import com.accenture.multibank.generator.AccountNumberGenerator;

public class SimpleAccountFactory implements AccountFactory {

	/**
	 * Creates an account with the account number generated by the given generator
	 * @param generator Generator wo be used to generate the account number
	 * @param accountType Type of the account
	 * @param balance Balance to be set on the account
	 * @return
	 */
	public AccountModifiable createAccount(AccountNumberGenerator generator, AccountType accountType, int balance) throws OperationNotSupportedException {
		int accNum = generator.generateAccountNumber();
		AccountModifiable acc = null;

		switch (accountType) {
			case SAVING:
				acc = new SavingAccount(accNum, balance);
				break;
			case CREDIT:
				acc = new CreditAccount(accNum, balance);
				break;
			default:
				throw new OperationNotSupportedException("Account type not supported yet");
		}

		return acc;
	}

}

@@ -882,16 +882,196 @@
 ption %7B%0A
+%09%09if (generator == null)%0A%09%09%09throw new NullPointerException(%22Generator can't be null%22);%0A%09%09if (accountType == null)%0A%09%09%09throw new NullPointerException(%22Account type not specified%22);%0A%0A
 %09%09int ac

add exception handling when either generator or account type is null