51 lines
1.1 KiB
C#
Raw Normal View History

2021-09-27 09:31:50 +13:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Week_10___Account_Library
{
public class Account
{
2021-09-27 10:44:54 +13:00
2021-09-27 09:31:50 +13:00
private decimal _balance;
private decimal _overdraftLimit;
public decimal Balance => _balance;
public decimal OverdraftLimit => _overdraftLimit;
2021-09-27 10:44:54 +13:00
public AccountState StateOfAccount { get; }
2021-09-27 09:31:50 +13:00
2021-09-27 10:44:54 +13:00
private bool ValidateAmount(decimal amount)
2021-09-27 09:31:50 +13:00
{
2021-09-27 10:44:54 +13:00
return amount >= 0;
2021-09-27 09:31:50 +13:00
}
2021-09-27 10:44:54 +13:00
public void Deposit(decimal amount)
2021-09-27 09:31:50 +13:00
{
2021-09-27 10:44:54 +13:00
if (ValidateAmount(amount))
_balance += amount;
}
public void Withdraw(decimal amount)
{
if (ValidateAmount(amount))
_balance -= amount;
2021-09-27 09:31:50 +13:00
}
public Account(decimal balance, decimal overdraftLimit)
{
_balance = balance;
_overdraftLimit = overdraftLimit;
}
}
2021-09-27 10:44:54 +13:00
public enum AccountState
{
Safe,
InOD,
ODLimit,
None
}
2021-09-27 09:31:50 +13:00
}