Leksjon 2 Marie Lister
This commit is contained in:
parent
32933758fe
commit
33328cee26
7 changed files with 96 additions and 11 deletions
|
@ -6,7 +6,7 @@ namespace BankAppMarie
|
|||
string _accountName;
|
||||
bool _savingsAccount;
|
||||
string _accountNumber;
|
||||
string[] _accountTransactions;
|
||||
List<string> _accountTransactions;
|
||||
|
||||
public void DepositMoney(int amountToDeposit)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ namespace BankAppMarie
|
|||
_balance -= amountToWithdraw;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
Console.WriteLine("Insufficient balance");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue