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.

  1. Create a method for adding a record about a client by id of a client (int).
    1. The method returns 0 in case of success. The initial value is 0.
    2. The method returns 100, if an account with the same id exists already.
  2. Create a method for getting value of an account by id of a client (int).
    1. The method returns an object {ErrorCode = 200, Result = 0} if there is no account for the specified id.
    2. The method has to return an object {ErrorCode = 0, Result = [value of the account]} in case of success.
  3. 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).
    1. The method returns 200 if there is no account for the specified id.
    2. The method returns 0 in case of success.
    3. The value of the account has to be changed accordingly to the operation.
    4. The method returns 300, if there is not enouth money (for withdrawal).
  4. Create a method, allowing to cancel the last operation by client's id (int).
    1. The method returns 200 if there is no account for the specified id.
    2. The method returns an object {ErrorCode = 0} (even if there is no history)
    3. The value of the account has to get back to the state before the last operation.
  5. The method of withdrawal/replenishment, in case of success, has to return {ErrorCode = 0, Result = "#[number of the operation]"}.
    1. 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.
    2. Cancelling of an operation doesn't influence on the number of operations counter.
  6. 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.