|I have no any experiences in any programming language before C++, thus my question might seem easy.|
Thanks for all the advise
Below is the assignment:
1. Define a BankAccount class as follows:
a. Declare four fields: account number (int), Account type (string), owner’s name (String), current balance (double). All fields have private access.
b. Declare a static field, NextAcntNbr, of type int. Initialize its value to 10001. Whenever a new account is created, value of this field is used as the Account Number of the new account. Its value is then incremented by one.
c. Define a constructor which assigns the account number of the new account. It also set the owner’s name and balance with the values it receives through the parameters. Set the account type as “GA” to indicate that this is a general account.
d. Define a debit method which subtracts a given positive amount from the current balance, then prints the information about this account. If there is not enough balance in the account, an error message should be printed.
e. Define a credit method which adds a given positive amount to the current balance, then prints the information about this account.
f. Define a getBalance method which returns the current balance.
g. Define a printAccount method which prints all the fields of an account.
2. Define a main method to test the BankAccount implementation. The main method should do the following:
a. Create an array object capable of storing 10 BankAccount objects.
b. Create several BankAccount objects and store them into the array.
c. Invoke the debit, credit, and getBalance methods to do some transactions. Make sure you print out some information about each transaction.
d. You may use a loop to perform steps b and c. Tasks inside the loop can be:
- display welcome message;
- ask user the transaction type (create new account, debit, credit, check balance, quit), then invoke proper method.
Or, you may want to just hardcode some test cases in your program to exercise all those methods. It’s your choice.
1. Run your program to create at least three test accounts. The first account should use your name as the owner. All the methods must be invoked at least once. Turn in both the program listing and the input/output dialog to show that your program runs correctly.