Leksjon 2 Marie Lister
This commit is contained in:
parent
32933758fe
commit
33328cee26
|
@ -6,7 +6,7 @@ namespace BankAppMarie
|
|||
string _accountName;
|
||||
bool _savingsAccount;
|
||||
string _accountNumber;
|
||||
string[] _accountTransactions;
|
||||
List<string> _accountTransactions;
|
||||
|
||||
public void DepositMoney(int amountToDeposit)
|
||||
{
|
||||
|
|
|
@ -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
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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<Bill> _bills;
|
||||
|
||||
public Customer(string customerName)
|
||||
{
|
||||
_customerName = customerName;
|
||||
_savingsAccount = new Account(true, "Savings");
|
||||
_currentAccount = new Account(false, "Brukskonto");
|
||||
_bills = new List<Bill>();
|
||||
}
|
||||
public Customer(string customerName, bool hasBills)
|
||||
{
|
||||
_customerName = customerName;
|
||||
_savingsAccount = new Account(true, "Savings");
|
||||
_currentAccount = new Account(false, "Brukskonto");
|
||||
_bills = new List<Bill>() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
16
Emne 3/ListerMarie/ListerMarie.sln
Normal file
16
Emne 3/ListerMarie/ListerMarie.sln
Normal file
|
@ -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
|
10
Emne 3/ListerMarie/ListerMarie/ListerMarie.csproj
Normal file
10
Emne 3/ListerMarie/ListerMarie/ListerMarie.csproj
Normal file
|
@ -0,0 +1,10 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
1
Emne 3/ListerMarie/ListerMarie/Program.cs
Normal file
1
Emne 3/ListerMarie/ListerMarie/Program.cs
Normal file
|
@ -0,0 +1 @@
|
|||
|
Loading…
Reference in a new issue