From 7616efbf770d97b9ba6396cadcfe817c54bec2fd Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Tue, 3 Dec 2024 13:40:12 +0100 Subject: [PATCH] removed dotnet 6 --- Emne 3/BankAppMarie/BankAppMarie/Account.cs | 9 +++++++++ Emne 3/BankAppMarie/BankAppMarie/Bank.cs | 1 + Emne 3/BankAppMarie/BankAppMarie/Bill.cs | 6 +++--- Emne 3/BankAppMarie/BankAppMarie/Customer.cs | 15 +++++++-------- Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje.sln | 16 ++++++++++++++++ .../TowersOfHanoiTerje/Program.cs | 2 ++ .../TowersOfHanoiTerje/TowersOfHanoiTerje.csproj | 10 ++++++++++ Emne 3/shell.nix | 2 -- 8 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje.sln create mode 100644 Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje/Program.cs create mode 100644 Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje/TowersOfHanoiTerje.csproj diff --git a/Emne 3/BankAppMarie/BankAppMarie/Account.cs b/Emne 3/BankAppMarie/BankAppMarie/Account.cs index 351e1a7..019329e 100644 --- a/Emne 3/BankAppMarie/BankAppMarie/Account.cs +++ b/Emne 3/BankAppMarie/BankAppMarie/Account.cs @@ -29,6 +29,15 @@ namespace BankAppMarie { _savingsAccount = isSavingsAccount; _accountName = accountName; + _balance = 10000; + _accountTransactions = new List(); + _accountNumber = new Guid().ToString(); + } + + public void AddNewTransaction(string transactionText) + { + _accountTransactions.Add(transactionText); + Console.WriteLine("Added: " + transactionText); } public int GetAccountBalance() diff --git a/Emne 3/BankAppMarie/BankAppMarie/Bank.cs b/Emne 3/BankAppMarie/BankAppMarie/Bank.cs index 0f364ea..84225ae 100644 --- a/Emne 3/BankAppMarie/BankAppMarie/Bank.cs +++ b/Emne 3/BankAppMarie/BankAppMarie/Bank.cs @@ -47,6 +47,7 @@ namespace BankAppMarie case "5": var accountBalance = _currentCustomer.GetAccountBalance(); Console.WriteLine($"{accountBalance}"); + Console.ReadLine(); break; case "6": isRunning = false; diff --git a/Emne 3/BankAppMarie/BankAppMarie/Bill.cs b/Emne 3/BankAppMarie/BankAppMarie/Bill.cs index b6d8bdb..40b7ab4 100644 --- a/Emne 3/BankAppMarie/BankAppMarie/Bill.cs +++ b/Emne 3/BankAppMarie/BankAppMarie/Bill.cs @@ -8,15 +8,15 @@ namespace BankAppMarie public string AccountNumber { get; set; } public string Sender { get; set; } public string KidNr { get; set; } - public int CustomerId { get; set; } + public int Id { get; set; } public DateTime PayDate { get; set; } - public Bill(int billAmount, string billNumber, DateTime timeToPay, int customerId) + public Bill(int billAmount, string billNumber, DateTime timeToPay, int id) { Amount = billAmount; KidNr = billNumber; PayDate = timeToPay; - CustomerId = customerId; + Id = id; } } diff --git a/Emne 3/BankAppMarie/BankAppMarie/Customer.cs b/Emne 3/BankAppMarie/BankAppMarie/Customer.cs index 8951356..6adc8b5 100644 --- a/Emne 3/BankAppMarie/BankAppMarie/Customer.cs +++ b/Emne 3/BankAppMarie/BankAppMarie/Customer.cs @@ -57,17 +57,15 @@ namespace BankAppMarie } 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($"Id: {bill.Id}.) KidNr: {bill.KidNr} Amount: {bill.Amount}DueDate: {bill.PayDate.ToShortDateString()}"); } - Console.WriteLine("Please selcet bill id:"); - var menuChoice = Convert.ToInt32(Console.ReadLine()); - + Console.WriteLine("Please selcet bill id to pay:"); + var billId = int.Parse(Console.ReadLine()); + PayBill(billId); } public void PayBill(int billId) @@ -75,11 +73,12 @@ namespace BankAppMarie var bill = GetBill(billId); _currentAccount.Withdraw(bill.Amount); _bills.Remove(bill); + _currentAccount.AddNewTransaction("Paid bill " + bill.KidNr); } public Bill GetBill(int billId) { - Bill foundBill = _bills.First(bill => bill.CustomerId == billId); + Bill foundBill = _bills.First(bill => bill.Id == billId); return foundBill; } } diff --git a/Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje.sln b/Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje.sln new file mode 100644 index 0000000..f365325 --- /dev/null +++ b/Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TowersOfHanoiTerje", "TowersOfHanoiTerje\TowersOfHanoiTerje.csproj", "{F15F32B0-1FC9-4D75-8EE4-942343B4DA3B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F15F32B0-1FC9-4D75-8EE4-942343B4DA3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F15F32B0-1FC9-4D75-8EE4-942343B4DA3B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F15F32B0-1FC9-4D75-8EE4-942343B4DA3B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F15F32B0-1FC9-4D75-8EE4-942343B4DA3B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje/Program.cs b/Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje/Program.cs new file mode 100644 index 0000000..c65238f --- /dev/null +++ b/Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje/Program.cs @@ -0,0 +1,2 @@ + + diff --git a/Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje/TowersOfHanoiTerje.csproj b/Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje/TowersOfHanoiTerje.csproj new file mode 100644 index 0000000..2f4fc77 --- /dev/null +++ b/Emne 3/TowersOfHanoiTerje/TowersOfHanoiTerje/TowersOfHanoiTerje.csproj @@ -0,0 +1,10 @@ + + + + Exe + net8.0 + enable + enable + + + diff --git a/Emne 3/shell.nix b/Emne 3/shell.nix index 9431d06..e791e67 100644 --- a/Emne 3/shell.nix +++ b/Emne 3/shell.nix @@ -5,8 +5,6 @@ mkShell { name = "dotnet-env"; packages = [ (with dotnetCorePackages; combinePackages [ - sdk_6_0 - sdk_7_0 sdk_8_0 sdk_9_0 ])