Here is my solution. Hope this is correct.
// SPDX-License-Identifier: MIT
pragma solidity 0.7.5;
contract Bank {
address owner;
mapping(address => uint) balance;
event depositDone(uint amount, address indexed depositedTo);
modifier onlyOwner {
require(msg.sender == owner);
_;
}
constructor() {
owner = msg.sender;
}
function deposit() public payable returns(uint) {
balance[msg.sender] += msg.value;
emit depositDone(msg.value, msg.sender);
return balance[msg.sender];
}
function getBalance() public view returns (uint) {
return balance[msg.sender];
}
function transfer(address receipient, uint _transferAmount) public returns(uint) {
balance[msg.sender] -= _transferAmount;
balance[receipient] += _transferAmount;
return balance[receipient];
}
function withdraw(uint amount) public payable returns (uint) {
require (balance[msg.sender] >= amount, "You don't have enough funds!");
uint previousBalance = balance[msg.sender];
balance[msg.sender] -= amount;
msg.sender.transfer (amount);
assert (balance[msg.sender] == previousBalance - amount);
return balance[msg.sender];
}
}