59 lines
1.5 KiB
C#
59 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ConsoleApp1
|
|
{
|
|
class Transaction
|
|
{
|
|
public string leiras;
|
|
public int osszeg;
|
|
public DateTime datum;
|
|
public bool ok = false;
|
|
|
|
public Transaction(Account kuldo, Account fogado, int ertek, string megjegyzes) {
|
|
this.osszeg = ertek;
|
|
kuldo.egyenleg -= osszeg;
|
|
fogado.egyenleg += osszeg;
|
|
datum = DateTime.Now;
|
|
leiras = megjegyzes;
|
|
ok = true;
|
|
|
|
if (ok)
|
|
{
|
|
kuldo.transactions.Add(this);
|
|
}
|
|
}
|
|
}
|
|
|
|
class Account{
|
|
public string Name { get; set; }
|
|
public Account(string nev) {
|
|
Name = nev;
|
|
}
|
|
|
|
public int egyenleg;
|
|
public List<Transaction> transactions = new List<Transaction>();
|
|
|
|
}
|
|
internal class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
Account valaki = new Account("Kis Józsi");
|
|
Account valaki2 = new Account("Nagy Józsi");
|
|
|
|
Transaction pez = new Transaction(valaki, valaki2, 100, "asd");
|
|
Transaction pez1 = new Transaction(valaki, valaki2, 100, "asd2");
|
|
Transaction pez2 = new Transaction(valaki, valaki2, 100, "asd4");
|
|
|
|
foreach (Transaction t in valaki.transactions)
|
|
{
|
|
Console.WriteLine(t.leiras);
|
|
}
|
|
}
|
|
}
|
|
}
|