Skip to content

Commit dd7bb33

Browse files
committed
2 parents 95b2065 + 8f74b3d commit dd7bb33

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+886
-4585
lines changed
-46.4 KB
Binary file not shown.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace BankApp
5+
{
6+
// TASK 1: Define the AccountType enum
7+
// TASK 1: Step 1 - Define the AccountType enum
8+
public enum AccountType
9+
{
10+
Checking,
11+
Savings,
12+
Business
13+
}
14+
15+
public static class AccountTypeExtensions
16+
{
17+
// TASK 1: Step 2 - Add an extension method to provide descriptions for each AccountType.
18+
public static string GetDescription(this AccountType accountType)
19+
{
20+
return accountType switch
21+
{
22+
AccountType.Checking => "A standard checking account.",
23+
AccountType.Savings => "A savings account with interest.",
24+
AccountType.Business => "A business account for companies.",
25+
_ => "Unknown account type."
26+
};
27+
}
28+
}
29+
30+
// TASK 2: Define the Transaction struct
31+
// TASK 2: Step 1 - Define the Transaction struct
32+
public readonly struct Transaction
33+
{
34+
public double Amount { get; }
35+
public DateTime Date { get; }
36+
public string Description { get; }
37+
38+
public Transaction(double amount, DateTime date, string description)
39+
{
40+
Amount = amount;
41+
Date = date;
42+
Description = description;
43+
}
44+
45+
public override string ToString()
46+
{
47+
return $"{Date.ToShortDateString()}: {Description} - {Amount:C}";
48+
}
49+
}
50+
51+
// TASK 3: Define the Customer record
52+
// TASK 3: Step 1 - Define the Customer record
53+
public record Customer(string Name, string CustomerId, string Address);
54+
55+
// TASK 4: Implement the BankAccount class
56+
// TASK 4: Step 1 - Add properties for AccountNumber, Balance, AccountHolder, and Type.
57+
public class BankAccount
58+
{
59+
public int AccountNumber { get; }
60+
public AccountType Type { get; }
61+
public Customer AccountHolder { get; }
62+
public double Balance { get; private set; }
63+
64+
// TASK 4: Step 2 - Add a constructor to initialize the properties.
65+
public BankAccount(int accountNumber, AccountType type, Customer accountHolder, double initialBalance = 0)
66+
{
67+
AccountNumber = accountNumber;
68+
Type = type;
69+
AccountHolder = accountHolder;
70+
Balance = initialBalance;
71+
}
72+
73+
// TASK 4: Step 3 - Add a method to deposit money into the account.
74+
public void AddTransaction(double amount, string description)
75+
{
76+
Balance += amount;
77+
Transactions.Add(new Transaction(amount, DateTime.Now, description));
78+
}
79+
80+
// TASK 4: Step 4 - Add a method to withdraw money from the account.
81+
public string DisplayAccountInfo()
82+
{
83+
return $"Account Holder: {AccountHolder.Name}, Account Number: {AccountNumber}, Type: {Type}, Balance: {Balance:C}";
84+
}
85+
86+
// TASK 4: Step 5 - Add a method to display account information.
87+
private List<Transaction> Transactions { get; } = new();
88+
89+
// TASK 4: Step 6 - Add a list to track transactions.
90+
public void DisplayTransactions()
91+
{
92+
Console.WriteLine("Transactions:");
93+
foreach (var transaction in Transactions)
94+
{
95+
Console.WriteLine(transaction);
96+
}
97+
}
98+
}
99+
}

DownloadableCodeProjects/LP4_manage-app-data/Data_M3/Solution/Data_M3.csproj

Lines changed: 0 additions & 10 deletions
This file was deleted.

DownloadableCodeProjects/LP4_manage-app-data/Data_M3/Solution/Interfaces/IBankAccount.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

DownloadableCodeProjects/LP4_manage-app-data/Data_M3/Solution/Interfaces/IBankCustomer.cs

Lines changed: 0 additions & 19 deletions
This file was deleted.

DownloadableCodeProjects/LP4_manage-app-data/Data_M3/Solution/Interfaces/IMonthlyReportGenerator.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

DownloadableCodeProjects/LP4_manage-app-data/Data_M3/Solution/Interfaces/IQuarterlyReportGenerator.cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

DownloadableCodeProjects/LP4_manage-app-data/Data_M3/Solution/Interfaces/IYearlyReportGenerator.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

DownloadableCodeProjects/LP4_manage-app-data/Data_M3/Solution/Models/Bank.cs

Lines changed: 0 additions & 132 deletions
This file was deleted.

0 commit comments

Comments
 (0)