#BankVersion1
Download or clone the C# project BankVersion1. This exercise is about defining a new class yourself! In the project, there is a file called BankAccount.cs, containing a definition of a class BankAccount. However, the definition is empty…
We have to fill out the class definition. The requirements to the bank account class are the following:
-
- It must have a name, which is the name of the account holder
- It must have a balance, which is a decimal number.
- It must have a method Deposit, which you can use for depositing an amount to the account (that is, the balance should increase
- It must have a method Withdraw, which you can use for withdrawing an amount from the account (that is, the balance should decrease)
- It must have methods for returning the value of the account holder name, and the value of the balance (one method for each value)
Given these requirement, your tasks are:
-
Fill out the BankAccount definition, such that all requirements are fulfilled. This includes definition of instance fields, constructors and methods.
-
Make some test code that tests your BankAccount class. That is, you should create a BankAccount object, call the withdraw/deposit methods, and use the available methods to check that the object behaves as expected with regards to the value of the balance.
-
If you have time left, try to extend the class definition with methods for adding interest to the account. It is up to you to define requirements, etc..
NOTE: This is a fairly large and somewhat difficult exercise. Try to solve it in small steps – get a little bit to work, test it, and then proceed to the next little bit. Manage the complexity!