144k views
0 votes
Take the BankAccount Class from the first program and copy it into this program. You will use it as one of the classes in this one.

Create a BankCustomer class with 3 BankAccount objects inside it as private variables (of type BankAccount) as well as one customer name (of type String). [The three accounts are for checking, savings, and money market.] The constructors you make are up to you in this BankCustomer class, you can create one or two or more overloaded constructors: full constructor, partial constructor, and/or non-arg constructor. Create getter and setter methods for these four attributes, three BankAccount variables and one String ustomerName, to work with these attributes. Create a method to get total balance of all 3 BankAccount objects.
In main method of BankCustomerTest class file, create two BankCustomers, with their names and all account information and the values in them for the user. Then add 1000 to the checking account of the first one and 500 to the savings account of the second one and print all account information and the values in them for the user to test your new class and working with its internal objects through the outer class.

1 Answer

1 vote

Final answer:

To create the BankCustomer class, you need to define private variables for the BankAccount objects and customer name. You also need to create constructors, getters, setters, and a method to calculate the total balance. In the main method, you can create instances of BankCustomer and test the class.

Step-by-step explanation:

To create the BankCustomer class, you need to define three private variables of type BankAccount (checking, savings, and money market) and one variable of type String (customerName). In this class, you can create multiple constructors, such as a full constructor, a partial constructor, and a non-arg constructor, depending on your needs.

Next, you need to create getter and setter methods for the four attributes (checking, savings, money market, and customerName) to interact with these variables.

To calculate the total balance of all three BankAccount objects, you can create a method that sums up the balances of the three accounts.

In the main method of the BankCustomerTest class, you can create two instances of BankCustomer, set their names and account information, and perform operations such as adding money to specific accounts. Finally, you can print out the account information and values to test the functionality of your BankCustomer class.

User Idrougge
by
7.1k points