51 lines
1.1 KiB
C#
51 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Week_10___Account_Library
|
|
{
|
|
public class Account
|
|
{
|
|
|
|
private decimal _balance;
|
|
private decimal _overdraftLimit;
|
|
|
|
public decimal Balance => _balance;
|
|
public decimal OverdraftLimit => _overdraftLimit;
|
|
public AccountState StateOfAccount { get; }
|
|
|
|
private bool ValidateAmount(decimal amount)
|
|
{
|
|
return amount >= 0;
|
|
}
|
|
|
|
public void Deposit(decimal amount)
|
|
{
|
|
if (ValidateAmount(amount))
|
|
_balance += amount;
|
|
}
|
|
|
|
public void Withdraw(decimal amount)
|
|
{
|
|
if (ValidateAmount(amount))
|
|
_balance -= amount;
|
|
}
|
|
|
|
public Account(decimal balance, decimal overdraftLimit)
|
|
{
|
|
_balance = balance;
|
|
_overdraftLimit = overdraftLimit;
|
|
}
|
|
}
|
|
|
|
public enum AccountState
|
|
{
|
|
Safe,
|
|
InOD,
|
|
ODLimit,
|
|
None
|
|
}
|
|
}
|