-
Notifications
You must be signed in to change notification settings - Fork 0
/
Account.cs
110 lines (94 loc) · 3.01 KB
/
Account.cs
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _422BankApplicationSharp
{
public class Account
{
//constructors
public Account(double initialBalance = 0.0,
int newAccountNumber = 0,
string newName = "",
string newDateCreated = "")
{
this.mBalance = initialBalance;
this.mAccountNumber = newAccountNumber;
this.mName = newName;
this.mDateCreated = newDateCreated;
}
public Account (Account copyAccount)
{
this.mAccountNumber = copyAccount.mAccountNumber;
this.mBalance = copyAccount.mBalance;
this.mDateCreated = copyAccount.mDateCreated;
this.mName = copyAccount.mName;
}
//Methods
/// <summary>
/// Adds money to an account
/// </summary>
/// <param name="newAmount">the amount to be added</param>
/// <returns>The new balance</returns>
public double credit (double newAmount)
{
mBalance += newAmount;
return mBalance;
}
/// <summary>
/// Attempts to debit an account by newAmount, and gives a warning if not enough money exists
/// </summary>
/// <param name="newAmount">The amount to be debited</param>
/// <returns>The resulting amount</returns>
public double debit(double newAmount)
{
if (newAmount > mBalance)
{
Console.WriteLine("Warning cannot withdraw " + newAmount + " exceeds your funds!");
}
else
{
mBalance -= newAmount;
}
return mBalance;
}
public void printBalance()
{
Console.WriteLine("A#: " + mAccountNumber);
Console.WriteLine("Name: " + mName);
Console.WriteLine("Current Balance: " + mBalance);
Console.WriteLine("Date Created: " +mDateCreated);
}
//Private variables
//The balance of the account
private double mBalance;
//The unique identifying account number
private int mAccountNumber;
//The name associated with the account
private string mName;
//The date the account was created, as a string.
private string mDateCreated;
//Getters and setters for the above
public double MBalance
{
get { return mBalance; }
set { mBalance = value; }
}
public int MAccountNumber
{
get { return mAccountNumber; }
set { mAccountNumber = value; }
}
public string MName
{
get { return mName; }
set { mName = value; }
}
public string MDateCreated
{
get { return mDateCreated; }
set { mDateCreated = value; }
}
}
}