Skip to content

Commit 98d8b76

Browse files
committed
LP6 M1 adding starter to solution
1 parent 1c769fa commit 98d8b76

28 files changed

+2133
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"ApprovedNames": [
3+
{ "FirstName": "Elize", "LastName": "Harmsen" },
4+
{ "FirstName": "Mattia", "LastName": "Trentini" },
5+
{ "FirstName": "Peter", "LastName": "Zammit" },
6+
{ "FirstName": "Lennart", "LastName": "Kangur" },
7+
{ "FirstName": "Erik", "LastName": "Valjas" },
8+
{ "FirstName": "Nedelya", "LastName": "Grigorova" },
9+
{ "FirstName": "Anette", "LastName": "Thomsen" },
10+
{ "FirstName": "Kasper", "LastName": "Frisk" },
11+
{ "FirstName": "Niki", "LastName": "Demetriou" },
12+
{ "FirstName": "Janez", "LastName": "Horvat" },
13+
{ "FirstName": "Petros", "LastName": "Doudis" },
14+
{ "FirstName": "Ivan", "LastName": "Krajnc" },
15+
{ "FirstName": "Cao", "LastName": "Huy" },
16+
{ "FirstName": "Phung", "LastName": "Hang" },
17+
{ "FirstName": "Gil", "LastName": "Gabbai" },
18+
{ "FirstName": "Maya", "LastName": "Meyerson" },
19+
{ "FirstName": "Suttida", "LastName": "Bunyasarn" },
20+
{ "FirstName": "Akkarat", "LastName": "Leelapun" },
21+
{ "FirstName": "Julia", "LastName": "Linares" },
22+
{ "FirstName": "Larissa", "LastName": "Sevilla" },
23+
{ "FirstName": "Renata", "LastName": "Amaya" },
24+
{ "FirstName": "Federico", "LastName": "Tercedor" },
25+
{ "FirstName": "Sergio", "LastName": "Valladares" },
26+
{ "FirstName": "Tatiana", "LastName": "Seleznyova" },
27+
{ "FirstName": "Vitaly", "LastName": "Toporov" },
28+
{ "FirstName": "Chingfan", "LastName": "Chou" },
29+
{ "FirstName": "Lai", "LastName": "Chou" },
30+
{ "FirstName": "Ethan", "LastName": "Brooks" },
31+
{ "FirstName": "Hannah", "LastName": "Haynes" },
32+
{ "FirstName": "Staffan", "LastName": "Bergqvist" },
33+
{ "FirstName": "Anna", "LastName": "Hedlund" },
34+
{ "FirstName": "Afshin", "LastName": "Behzadi" },
35+
{ "FirstName": "Elaheh", "LastName": "Mansouri" },
36+
{ "FirstName": "Rayna", "LastName": "Bacheva" },
37+
{ "FirstName": "Milena", "LastName": "Stoichkova" },
38+
{ "FirstName": "Rayko", "LastName": "Dimitrov" },
39+
{ "FirstName": "Saki", "LastName": "Yoshida" },
40+
{ "FirstName": "Jun", "LastName": "Uchida" },
41+
{ "FirstName": "Hannah", "LastName": "Weber" },
42+
{ "FirstName": "Conrad", "LastName": "Nuber" },
43+
{ "FirstName": "Erna", "LastName": "Nilsson" },
44+
{ "FirstName": "Viktor", "LastName": "Magnusson" },
45+
{ "FirstName": "Genevieve", "LastName": "Arcouet" },
46+
{ "FirstName": "Alain", "LastName": "Davignon" },
47+
{ "FirstName": "Danielle", "LastName": "Brasseur" },
48+
{ "FirstName": "Claude", "LastName": "Aupry" },
49+
{ "FirstName": "Chung-Ae", "LastName": "Ryang" },
50+
{ "FirstName": "Bong-Jin", "LastName": "Lee" },
51+
{ "FirstName": "Faruk", "LastName": "Keskin" },
52+
{ "FirstName": "Yasemin", "LastName": "Ozkan" }
53+
]
54+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<!-- Include all files in the Config folder and copy them to the output directory -->
12+
<Content Include="Config\**\*">
13+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
14+
</Content>
15+
</ItemGroup>
16+
17+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace Delegates;
2+
3+
public interface IBankAccount
4+
{
5+
int AccountNumber { get; }
6+
string CustomerId { get; }
7+
double Balance { get; }
8+
string AccountType { get; }
9+
double InterestRate { get; }
10+
BankCustomer Owner { get; } // This is the BankCustomer object that owns the account
11+
IEnumerable<Transaction> Transactions { get; } // List of transactions for the account
12+
13+
void Deposit(double amount, DateOnly transactionDate, TimeOnly transactionTime, string description);
14+
bool Withdraw(double amount, DateOnly transactionDate, TimeOnly transactionTime, string description);
15+
bool Transfer(IBankAccount targetAccount, double amount, DateOnly transactionDate, TimeOnly transactionTime, string description);
16+
void ApplyInterest(double years, DateOnly transactionDate, TimeOnly transactionTime, string description);
17+
void ApplyRefund(double refund, DateOnly transactionDate, TimeOnly transactionTime, string description);
18+
bool IssueCashiersCheck(double amount, DateOnly transactionDate, TimeOnly transactionTime, string description);
19+
string DisplayAccountInfo();
20+
void AddTransaction(Transaction transaction);
21+
List<Transaction> GetAllTransactions();
22+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace Delegates;
2+
3+
public interface IBankCustomer
4+
{
5+
string FirstName { get; set; }
6+
string LastName { get; set; }
7+
string CustomerId { get; }
8+
IReadOnlyList<IBankAccount> Accounts { get; }
9+
10+
string ReturnFullName();
11+
void UpdateName(string firstName, string lastName);
12+
string DisplayCustomerInfo();
13+
bool IsPremiumCustomer();
14+
void ApplyBenefits();
15+
void AddAccount(IBankAccount account);
16+
void RemoveAccount(IBankAccount account);
17+
IEnumerable<IBankAccount> GetAllAccounts();
18+
IEnumerable<IBankAccount> GetAccountsByType(string accountType);
19+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
3+
namespace Delegates;
4+
5+
public interface IMonthlyReportGenerator
6+
{
7+
void GenerateMonthlyReport(BankCustomer bankCustomer, int accountNumber, DateOnly reportDate);
8+
void GenerateCurrentMonthToDateReport(BankCustomer bankCustomer, int accountNumber, DateOnly reportDate);
9+
void GeneratePrevious30DayReport(BankCustomer bankCustomer, int accountNumber, DateOnly reportDate);
10+
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System;
2+
3+
namespace Delegates;
4+
5+
public interface IQuarterlyReportGenerator
6+
{
7+
void GenerateQuarterlyReport(BankCustomer bankCustomer, int accountNumber, DateOnly reportDate);
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
3+
namespace Delegates;
4+
5+
public interface IYearlyReportGenerator
6+
{
7+
void GeneratePreviousYearReport(BankCustomer bankCustomer, int accountNumber, DateOnly reportDate);
8+
void GenerateCurrentYearToDateReport(BankCustomer bankCustomer, int accountNumber, DateOnly reportDate);
9+
void GenerateLast365DaysReport(BankCustomer bankCustomer, int accountNumber, DateOnly reportDate);
10+
}
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace Delegates;
5+
6+
public class Bank
7+
{
8+
// Fields
9+
private readonly Guid _bankId;
10+
private readonly List<BankCustomer> _customers;
11+
12+
// Properties
13+
public Guid BankId => _bankId;
14+
public IReadOnlyList<BankCustomer> Customers => _customers.AsReadOnly();
15+
16+
// Constructors
17+
public Bank()
18+
{
19+
_bankId = Guid.NewGuid();
20+
_customers = new List<BankCustomer>();
21+
}
22+
23+
// Methods
24+
internal IEnumerable<BankCustomer> GetAllCustomers()
25+
{
26+
return new List<BankCustomer>(_customers);
27+
}
28+
29+
internal IEnumerable<BankCustomer> GetCustomersByName(string firstName, string lastName)
30+
{
31+
List<BankCustomer> matchingCustomers = new List<BankCustomer>();
32+
foreach (var customer in _customers)
33+
{
34+
if (customer.FirstName.Equals(firstName, StringComparison.OrdinalIgnoreCase) &&
35+
customer.LastName.Equals(lastName, StringComparison.OrdinalIgnoreCase))
36+
{
37+
matchingCustomers.Add(customer);
38+
}
39+
}
40+
return matchingCustomers;
41+
}
42+
43+
// get customer based on Customer ID
44+
internal BankCustomer? GetCustomerById(string customerId)
45+
{
46+
return _customers.FirstOrDefault(customer => customer.CustomerId.Equals(customerId, StringComparison.OrdinalIgnoreCase));
47+
48+
}
49+
50+
internal int GetNumberOfTransactions()
51+
{
52+
int totalTransactions = 0;
53+
foreach (BankCustomer customer in _customers)
54+
{
55+
foreach (BankAccount account in customer.Accounts)
56+
{
57+
foreach (Transaction transaction in account.Transactions)
58+
{
59+
totalTransactions++;
60+
}
61+
}
62+
}
63+
return totalTransactions;
64+
}
65+
66+
internal double GetTotalMoneyInVault()
67+
{
68+
double totalBankCash = 0;
69+
foreach (BankCustomer customer in _customers)
70+
{
71+
foreach (BankAccount account in customer.Accounts)
72+
{
73+
totalBankCash += account.Balance;
74+
}
75+
}
76+
return totalBankCash;
77+
}
78+
79+
internal double GetDailyDeposits(DateOnly date)
80+
{
81+
double totalDailyDeposits = 0;
82+
foreach (BankCustomer customer in _customers)
83+
{
84+
foreach (BankAccount account in customer.Accounts)
85+
{
86+
foreach (Transaction transaction in account.Transactions)
87+
{
88+
if (transaction.TransactionDate == date && transaction.TransactionType == "Deposit")
89+
{
90+
totalDailyDeposits += transaction.TransactionAmount;
91+
}
92+
}
93+
}
94+
}
95+
return totalDailyDeposits;
96+
}
97+
98+
internal double GetDailyWithdrawals(DateOnly date)
99+
{
100+
double totalDailyWithdrawals = 0;
101+
foreach (BankCustomer customer in _customers)
102+
{
103+
foreach (BankAccount account in customer.Accounts)
104+
{
105+
foreach (Transaction transaction in account.Transactions)
106+
{
107+
if (transaction.TransactionDate == date && transaction.TransactionType == "Withdraw")
108+
{
109+
totalDailyWithdrawals += transaction.TransactionAmount;
110+
}
111+
}
112+
}
113+
}
114+
return totalDailyWithdrawals;
115+
}
116+
117+
internal void AddCustomer(BankCustomer customer)
118+
{
119+
_customers.Add(customer);
120+
}
121+
122+
internal void RemoveCustomer(BankCustomer customer)
123+
{
124+
_customers.Remove(customer);
125+
}
126+
127+
internal void AddCustomers(IEnumerable<BankCustomer> customers)
128+
{
129+
_customers.AddRange(customers);
130+
}
131+
}

0 commit comments

Comments
 (0)