diff --git a/Emne 3/BankAppMarie/BankAppMarie/Account.cs b/Emne 3/BankAppMarie/BankAppMarie/Account.cs index de081f3..351e1a7 100644 --- a/Emne 3/BankAppMarie/BankAppMarie/Account.cs +++ b/Emne 3/BankAppMarie/BankAppMarie/Account.cs @@ -6,7 +6,7 @@ namespace BankAppMarie string _accountName; bool _savingsAccount; string _accountNumber; - string[] _accountTransactions; + List _accountTransactions; public void DepositMoney(int amountToDeposit) { @@ -20,7 +20,7 @@ namespace BankAppMarie _balance -= amountToWithdraw; } else - { + { Console.WriteLine("Insufficient balance"); } } diff --git a/Emne 3/BankAppMarie/BankAppMarie/Bank.cs b/Emne 3/BankAppMarie/BankAppMarie/Bank.cs index 9627a7b..0f364ea 100644 --- a/Emne 3/BankAppMarie/BankAppMarie/Bank.cs +++ b/Emne 3/BankAppMarie/BankAppMarie/Bank.cs @@ -6,7 +6,7 @@ namespace BankAppMarie public Bank() { - _currentCustomer = new Customer("Kåre Knutsen"); + _currentCustomer = new Customer("Kåre Knutsen", true); BankMenu(); } void BankMenu() @@ -14,6 +14,7 @@ namespace BankAppMarie var isRunning = true; while (isRunning) { + Console.Clear(); Console.WriteLine($"Welcome to the Bank app, {_currentCustomer.GetCustomerName()}!"); Console.WriteLine("1. Deposit Money"); Console.WriteLine("2. Withdraw Money"); @@ -39,6 +40,7 @@ namespace BankAppMarie _currentCustomer.WithdrawMoney(userInputInt, true); break; case "3": + _currentCustomer.PrintBills(); break; case "4": break; @@ -52,5 +54,7 @@ namespace BankAppMarie } } } + + } } \ No newline at end of file diff --git a/Emne 3/BankAppMarie/BankAppMarie/Bill.cs b/Emne 3/BankAppMarie/BankAppMarie/Bill.cs index 10e55ee..b6d8bdb 100644 --- a/Emne 3/BankAppMarie/BankAppMarie/Bill.cs +++ b/Emne 3/BankAppMarie/BankAppMarie/Bill.cs @@ -1,11 +1,25 @@ +using System.Security.Cryptography; + namespace BankAppMarie { public class Bill { - int _amount; - string _accountNumber; - string _sender; - string _kidNr; - DateTime _payDate; + public int Amount { get; private set; } + public string AccountNumber { get; set; } + public string Sender { get; set; } + public string KidNr { get; set; } + public int CustomerId { get; set; } + public DateTime PayDate { get; set; } + + public Bill(int billAmount, string billNumber, DateTime timeToPay, int customerId) + { + Amount = billAmount; + KidNr = billNumber; + PayDate = timeToPay; + CustomerId = customerId; + + } } -} \ No newline at end of file + + +} diff --git a/Emne 3/BankAppMarie/BankAppMarie/Customer.cs b/Emne 3/BankAppMarie/BankAppMarie/Customer.cs index de0841a..8951356 100644 --- a/Emne 3/BankAppMarie/BankAppMarie/Customer.cs +++ b/Emne 3/BankAppMarie/BankAppMarie/Customer.cs @@ -1,3 +1,5 @@ +using System.Transactions; + namespace BankAppMarie { internal class Customer @@ -6,14 +8,26 @@ namespace BankAppMarie string _socialSecurityNumber; Account _savingsAccount; Account _currentAccount; + List _bills; public Customer(string customerName) { _customerName = customerName; _savingsAccount = new Account(true, "Savings"); _currentAccount = new Account(false, "Brukskonto"); + _bills = new List(); } - + public Customer(string customerName, bool hasBills) + { + _customerName = customerName; + _savingsAccount = new Account(true, "Savings"); + _currentAccount = new Account(false, "Brukskonto"); + _bills = new List() { + new Bill(2221233, "123456645744", new DateTime(2024,12,24),1), + new Bill(1111133, "123124141666", new DateTime(2024,12,24),2), + new Bill(2234444, "345679086667", new DateTime(2025,01,3),3) + }; + } public string GetCustomerName() { @@ -41,6 +55,32 @@ namespace BankAppMarie { return _currentAccount.GetAccountBalance(); } - + public void PrintBills() + { + var billNr = 1; + Console.Clear(); + foreach (Bill bill in _bills) + { + Console.WriteLine($"{billNr}.) KidNr: {bill.KidNr} Amount: {bill.Amount}DueDate: {bill.PayDate}"); + billNr++; + + } + Console.WriteLine("Please selcet bill id:"); + var menuChoice = Convert.ToInt32(Console.ReadLine()); + + } + + public void PayBill(int billId) + { + var bill = GetBill(billId); + _currentAccount.Withdraw(bill.Amount); + _bills.Remove(bill); + } + + public Bill GetBill(int billId) + { + Bill foundBill = _bills.First(bill => bill.CustomerId == billId); + return foundBill; + } } } \ No newline at end of file diff --git a/Emne 3/ListerMarie/ListerMarie.sln b/Emne 3/ListerMarie/ListerMarie.sln new file mode 100644 index 0000000..f2f8d72 --- /dev/null +++ b/Emne 3/ListerMarie/ListerMarie.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ListerMarie", "ListerMarie\ListerMarie.csproj", "{D71EA117-6D8A-4AA2-8E28-79AED619907F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D71EA117-6D8A-4AA2-8E28-79AED619907F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D71EA117-6D8A-4AA2-8E28-79AED619907F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D71EA117-6D8A-4AA2-8E28-79AED619907F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D71EA117-6D8A-4AA2-8E28-79AED619907F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Emne 3/ListerMarie/ListerMarie/ListerMarie.csproj b/Emne 3/ListerMarie/ListerMarie/ListerMarie.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/Emne 3/ListerMarie/ListerMarie/ListerMarie.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Emne 3/ListerMarie/ListerMarie/Program.cs b/Emne 3/ListerMarie/ListerMarie/Program.cs new file mode 100644 index 0000000..5f28270 --- /dev/null +++ b/Emne 3/ListerMarie/ListerMarie/Program.cs @@ -0,0 +1 @@ + \ No newline at end of file