package bank; /** * A type of BankAccount that includes a joint owner in addition to * the owner provided by BankAccount */ public class JointBankAccount extends BankAccount { private String jointName; /** * Construct a joint bank account with given account number, * owner name, joint owner name and initial balance. * @param accountNumber the account number * @param ownerName the account owner name * @param jointOwnerName the account joint owner * @param initialBalance the initial account balance * @throws IllegalArgumentException if account number is negative, * owner or joint owner name is null or empty, or if balance is negative. */ public JointBankAccount(int accountNumber, String ownerName, String jointOwnerName, double initialBalance) { super(accountNumber, ownerName, initialBalance); if (jointOwnerName.equals("") || jointOwnerName == null) throw new IllegalArgumentException("Joint owner name not defined"); jointName = jointOwnerName; } /** * Return the joint owner name. * @return the joint owner name. */ public String getJointName() { return jointName; } /** * string representation of this account. * @return string representation of this account. */ public String toString() { return "JointBankAccount[" + super.toString() + ", " + jointName + "]"; } }