-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.cs
More file actions
68 lines (66 loc) · 2.02 KB
/
Copy pathAccount.cs
File metadata and controls
68 lines (66 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ATMCaseStudyApplication
{
// Account.cs
// Class Account represents a bank account.
public class Account
{
private int accountNumber; // account number
private int pin; // PIN for authentication
private decimal availableBalance; // available withdrawal amount
private decimal totalBalance; // funds available + pending deposit
// four-parameter constructor initializes attributes
public Account(int theAccountNumber, int thePIN,
decimal theAvailableBalance, decimal theTotalBalance)
{
accountNumber = theAccountNumber;
pin = thePIN;
availableBalance = theAvailableBalance;
totalBalance = theTotalBalance;
}
// read-only property that gets the account number
public int AccountNumber
{
get
{
return accountNumber;
}
}
// read-only property that gets the available balance
public decimal AvailableBalance
{
get
{
return availableBalance;
}
}
// read-only property that gets the total balance
public decimal TotalBalance
{
get
{
return totalBalance;
}
}
// determines whether a user-specified PIN matches PIN in Account
public bool ValidatePIN(int userPIN)
{
return (userPIN == pin);
}
// credits the account (funds have not yet cleared)
public void Credit(decimal amount)
{
totalBalance += amount; // add to total balance
}
// debits the account
public void Debit(decimal amount)
{
availableBalance -= amount; // subtract from available balance
totalBalance -= amount; // subtract from total balance
}
}
}