-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBankAccount.cs
More file actions
54 lines (47 loc) · 1.42 KB
/
BankAccount.cs
File metadata and controls
54 lines (47 loc) · 1.42 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Sandbox
{
public class BankAccount
{
// Two instance fields for representing the name of the account holder,
// and the current balance of the account
private String accountHolderName;
private double balance;
// Constructor - a name MUST be provided
public BankAccount(String name)
{
accountHolderName = name;
balance = 0.0;
}
// Deposit the specified amount into the account
public void Deposit(double amount)
{
balance = balance + amount;
}
// Withdraw the specified amount from the account
public void Withdraw(double amount)
{
balance = balance - amount;
}
// Return the current balance of the account
public double GetBalance()
{
return balance;
}
// Return the name of the bank account holder
public String GetName()
{
return accountHolderName;
}
// Interest is here just defined as a simple percentage
// of the current balance (not quite realistic...)
public void AssignInterest(double interestPercentage)
{
double interest = balance * (interestPercentage / 100.0);
balance = balance + interest;
}
}
}