The bank account
Video
If you are too lazy to constantly recreate projects for kata, download bat. You can read how to use it here
Task
Write a class, which is responsible for operations with a bank account of users.
Acceptance criteria
All the code should be covered by tests.
- Create a method for adding a record about a client by id of a client (int).
- The method returns 0 in case of success. The initial value is 0.
- The method returns 100, if an account with the same id exists already.
- Create a method for getting value of an account by id of a client (int).
- The method returns an object {ErrorCode = 200, Result = 0} if there is no account for the specified id.
- The method has to return an object {ErrorCode = 0, Result = [value of the account]} in case of success.
- Create a method of withdrawal/replenishment of an account, which takes id of a client (int) and the sum of the operation (negative number in case of withdrawal).
- The method returns 200 if there is no account for the specified id.
- The method returns 0 in case of success.
- The value of the account has to be changed accordingly to the operation.
- The method returns 300, if there is not enouth money (for withdrawal).
- Create a method, allowing to cancel the last operation by client's id (int).
- The method returns 200 if there is no account for the specified id.
- The method returns an object {ErrorCode = 0} (even if there is no history)
- The value of the account has to get back to the state before the last operation.
- The method of withdrawal/replenishment, in case of success, has to return {ErrorCode = 0, Result = "#[number of the operation]"}.
- The number of the operation is not depend on a concrete client and show common number of operations, which have done by an instance of the class.
- Cancelling of an operation doesn't influence on the number of operations counter.
- Allow to cancel any number of operations, adding a second parameter to the method from paragraph 5 - the number of cancelling operations.
Time criteria
Normal result for a non-junior developer should be spending up to 30 minutes to implement all the requirements.