A. Create a BankAccount class. We want to be able to create a new bank account, make deposits and withdrawals, and check the balance. Each bank account created should receive a unique account id, numbered sequentially 1001, 1002, 1003, and so on. We should be able to change the name on the account. We should also be able to retrieve the account id and the name on the account. Provide a constructor that takes a name for the account as a parameter. Remember that a constructor has the same name as the class. The constructor should initialize all of the instance variables. What does the class need to remember? Those are the instance variables. There should be three. Provide the following methods: public double getID() gets the account id of this BankAccount public double getBalance() gets the balance of this BankAccount public String getName() gets the name of this BankAccount public void setName(String newName) sets a new name for this BankAccount public void deposit(double amount) deposits an amount into this BankAccount public void withdraw(double amount) withdraws an amount from this BankAccount The next step is to write stubs for all the methods.
A. Create a BankAccount class.
We want to be able to create a new bank account, make deposits and withdrawals, and check the balance. Each bank account created should receive a unique account id, numbered sequentially 1001, 1002, 1003, and so on. We should be able to change the name on the account. We should also be able to retrieve the account id and the name on the account.
Provide a constructor that takes a name for the account as a parameter. Remember that a constructor has the same name as the class. The constructor should initialize all of the instance variables.
What does the class need to remember? Those are the instance variables. There should be three.
Provide the following methods:
- public double getID() gets the account id of this BankAccount
- public double getBalance() gets the balance of this BankAccount
- public String getName() gets the name of this BankAccount
- public void setName(String newName) sets a new name for this BankAccount
- public void deposit(double amount) deposits an amount into this BankAccount
- public void withdraw(double amount) withdraws an amount from this BankAccount
The next step is to write stubs for all the methods.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images