Write a Java Class file for the class Account that represents a bank account. Usually, a bank account has a unique account number that is used to identify it. Your class should generate the account number automatically whenever a new account is created. The class should also store the account balance in a data member. All the data members should be declared as private. You class should provide the following methods:
1. a constructor that takes the starting balances as an input then uses it to initialize the balance data member. The constructor should generate an account number automatically and store it in the account number data member. Account numbers should be sequential starting from 20101.
2. getAccountNumber: returns the account number.
3. getBalance: returns the current account balance.
4. debitAccount: adds funds to the account. It takes the amount to be deducted as a parameter then subtracts it from the balance.
5. creditAccount: adds funds to the account. It takes the amount to be credited as a parameter then adds it to the balance.
6. transferFunds: transferfunds from the account to another account. It has two parameter, the Account object of the account to which the transfer is made and the amount to be transferred.
triplea_2005 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.