-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
97 lines (78 loc) · 3.87 KB
/
Program.cs
File metadata and controls
97 lines (78 loc) · 3.87 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
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
using BankSimulator.Interfaces;
using BankSimulator.Models;
using BankSimulator.Interfaces.Services;
namespace BankSimulator
{
public class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to the Bank Simulator!\n");
// 1️⃣ Create Customers
IEncryptor encryptor = new EncryptionService();
var customer1 = new Customer(1001, "RaySha", encryptor);
customer1.SetPassword("password123");
var customer2 = new Customer(1002, "Taylor", encryptor);
customer2.SetPassword("secure456");
// 2️⃣ Create Accounts for Customers
var savings1 = new SavingsAccount("12345", "RaySha Savings", 5000, DateTime.Now);
var checking1 = new CheckingAccount("67890", "RaySha Checking", 3000, DateTime.Now);
var savings2 = new SavingsAccount("54321", "Taylor Savings", 4000, DateTime.Now);
var checking2 = new CheckingAccount("09876", "Taylor Checking", 2000, DateTime.Now);
// Add accounts to customers
customer1.AddAccount(savings1);
customer1.AddAccount(checking1);
customer2.AddAccount(savings2);
customer2.AddAccount(checking2);
Console.WriteLine("Customers and Accounts Created!\n");
// 3️⃣ Deposit and Withdraw
IBankAccount accountService = new BankAccountService();
accountService.Deposit(1000, savings1, "Savings");
accountService.Withdraw(500, checking1, "Checking");
accountService.Deposit(1500,savings2, "Savings");
accountService.Withdraw(1000,checking2, "Checking");
Console.WriteLine("💰 Basic Deposits and Withdrawals Completed!\n");
// 4️⃣ Transfer Funds (Savings → Checking)
accountService.Transfer(2000, savings1, checking1);
Console.WriteLine("🔄 Transfer Completed: 2000 from Savings → Checking\n");
// 5️⃣ Display All Account Balances
Console.WriteLine("📊 Account Summaries for RaySha:");
foreach (var summary in customer1.GetAccountSummaries())
{
Console.WriteLine($" {summary.AccountNumber} → Balance: {summary.Balance}");
}
Console.WriteLine("\n📊 Account Summaries for Taylor:");
foreach (var summary in customer2.GetAccountSummaries())
{
Console.WriteLine($" {summary.AccountNumber} → Balance: {summary.Balance}");
}
var firstTransaction = savings1[0]; // using indexer!
Console.WriteLine($"\nIndexer Example of RaySha→ First transaction: {firstTransaction}");
// 6️⃣ Display All Transactions for RaySha's Accounts
Console.WriteLine("\n📜 Transaction History (RaySha Savings):");
foreach (var t in savings1.Transactions)
{
Console.WriteLine(t.ToString());
}
Console.WriteLine("\n📜 Transaction History (RaySha Checking):");
foreach (var t in checking1.Transactions)
{
Console.WriteLine(t.ToString());
}
// Get transactions
ITransactionService transaction = new TransactionServices();
System.Console.WriteLine("\n\nGetTransactions\n");
var saving1Transaction = transaction.GetTransactions(savings1);
foreach (var st in saving1Transaction)
{
System.Console.WriteLine(st);
}
var checking1Transaction = transaction.GetTransactions(checking1);
foreach (var ct in checking1Transaction)
{
System.Console.WriteLine(ct);
}
Console.WriteLine("\n🏁 Program Finished Successfully!");
}
}
}