-
Notifications
You must be signed in to change notification settings - Fork 0
/
Account.cs
90 lines (85 loc) · 2.84 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MidProject2
{
class Account
{
private int accountNumber;
private string accountName;
private double balance;
private Address address;
public Account(int accountNumber, string accountName, double balance, Address address)
{
this.accountNumber = accountNumber;
this.accountName = accountName;
this.balance = balance;
this.address = address;
}
public int AccountNumber
{
set { this.accountNumber = value; }
get { return this.accountNumber; }
}
public string AccountName
{
set { this.accountName = value; }
get { return this.accountName; }
}
public double Balance
{
set { this.balance = value; }
get { return this.balance; }
}
public Address Address
{
set { this.address = value; }
get { return this.address; }
}
public abstract void Withdraw(double ammount)
{
if (balance < ammount && balance == 0)
{
Console.WriteLine("_____NOT ENOUGH BALANCE/INVALID BALANCE_____");
}
else
{
Console.WriteLine("_____WITHDRAW DONE SUCCESFULLY_____");
balance -= ammount;
Console.WriteLine("Current Balance: "+ this.balance );
}
}
public void Diposit(double ammount)
{
Console.WriteLine("_____DIPOSIT SUCCESSFUL_____");
balance += ammount;
Console.WriteLine("Current Balance: " + this.balance );
}
public void Transfer(Account receiver, double ammount)
{
if (balance < ammount && balance == 0)
{
Console.WriteLine("_____NOT ENOUGH BALANCE/INVALID BALANCE_____");
}
else
{
Console.WriteLine("_____TRANSFER SUCCESSFULLY_____");
this.balance -= ammount;
Console.WriteLine("Current Balance: " + this.balance );
receiver.Balance += ammount;
}
}
public void ChangeName(string name)
{
accountName = name;
Console.WriteLine("New Account name :" + this.accountName);
}
public abstract void ShowAccountInfo()
{
Console.WriteLine("ACCOUNT INFORMATION :\n" + "Account Number: " + this.accountNumber +
"\nName: " + this.accountName + "\nBalance: " + this.balance + "\nAddress: " + address.getAddress());
}
}
}