Enhance code documentation with comments for Bankrekening and Transactie classes, and adjust MainForm layout for improved UI consistency

This commit is contained in:
vista-man
2025-01-27 19:25:48 +01:00
parent fd28e1a375
commit 1de1230437
12 changed files with 38 additions and 18 deletions

View File

@@ -4,12 +4,14 @@ using System.Drawing;
using System.Windows.Forms;
#region Bankrekening Class
// Class representing a bank account
class Bankrekening
{
public string Rekeningnummer { get; }
private decimal saldo;
private List<Transactie> transacties;
public string Rekeningnummer { get; } // Account number
private decimal saldo; // Account balance
private List<Transactie> transacties; // List of transactions
// Constructor to initialize account number and starting balance
public Bankrekening(string rekeningnummer, decimal beginsaldo)
{
Rekeningnummer = rekeningnummer;
@@ -17,6 +19,7 @@ class Bankrekening
transacties = new List<Transactie>();
}
// Method to deposit money into the account
public void Storten(decimal bedrag)
{
if (bedrag > 0)
@@ -30,6 +33,7 @@ class Bankrekening
}
}
// Method to withdraw money from the account
public void Opnemen(decimal bedrag)
{
if (bedrag > 0 && bedrag <= saldo)
@@ -43,11 +47,13 @@ class Bankrekening
}
}
// Method to check the current balance
public decimal ControleerSaldo()
{
return saldo;
}
// Method to get the transaction history
public List<Transactie> GetTransactieGeschiedenis()
{
return transacties;
@@ -56,12 +62,14 @@ class Bankrekening
#endregion
#region Transactie Class
// Class representing a transaction
class Transactie
{
public decimal Bedrag { get; }
public string Beschrijving { get; }
public DateTime Datum { get; }
public decimal Bedrag { get; } // Transaction amount
public string Beschrijving { get; } // Transaction description
public DateTime Datum { get; } // Transaction date
// Constructor to initialize transaction details
public Transactie(decimal bedrag, string beschrijving)
{
Bedrag = bedrag;
@@ -72,15 +80,17 @@ class Transactie
#endregion
#region MainForm Class
// Main form for the application
public class MainForm : Form
{
private Bankrekening mijnRekening;
private Label saldoLabel;
private TextBox bedragTextBox;
private Button stortenButton;
private Button opnemenButton;
private Button transactieGeschiedenisButton;
private Bankrekening mijnRekening; // Bank account instance
private Label saldoLabel; // Label to display balance
private TextBox bedragTextBox; // TextBox to input amount
private Button stortenButton; // Button to deposit money
private Button opnemenButton; // Button to withdraw money
private Button transactieGeschiedenisButton; // Button to view transaction history
// Constructor to initialize the form and its controls
public MainForm()
{
mijnRekening = new Bankrekening("NL01BANK0123456789", 1000);
@@ -112,6 +122,7 @@ public class MainForm : Form
Top = 100,
Left = 20,
Width = 260,
Height = 50, // Adjusted height
Font = new Font("Arial", 14),
BackColor = Color.FromArgb(0, 123, 255),
ForeColor = Color.White,
@@ -120,29 +131,34 @@ public class MainForm : Form
opnemenButton = new Button()
{
Text = "Opnemen",
Top = 140,
Top = 160,
Left = 20,
Width = 260,
Height = 50, // Adjusted height
BackColor = Color.FromArgb(0, 123, 255), // Lighter blue
Font = new Font("Arial", 14, FontStyle.Bold), // Bold and larger font
ForeColor = Color.White,
FlatStyle = FlatStyle.Flat
};
transactieGeschiedenisButton = new Button()
{
Text = "Transactiegeschiedenis",
Top = 180,
Top = 220,
Left = 20,
Width = 260,
Height = 50, // Adjusted height
Font = new Font("Arial", 14),
BackColor = Color.FromArgb(108, 117, 125),
ForeColor = Color.White,
FlatStyle = FlatStyle.Flat
};
// Event handlers for button clicks
stortenButton.Click += StortenButton_Click;
opnemenButton.Click += OpnemenButton_Click;
transactieGeschiedenisButton.Click += TransactieGeschiedenisButton_Click;
// Add controls to the form
Controls.Add(saldoLabel);
Controls.Add(bedragTextBox);
Controls.Add(stortenButton);
@@ -150,11 +166,12 @@ public class MainForm : Form
Controls.Add(transactieGeschiedenisButton);
Text = "Bankrekening Beheer";
Size = new Size(320, 320);
Size = new Size(320, 380);
StartPosition = FormStartPosition.CenterScreen;
BackColor = Color.White;
}
// Event handler for deposit button click
private void StortenButton_Click(object sender, EventArgs e)
{
try
@@ -169,6 +186,7 @@ public class MainForm : Form
}
}
// Event handler for withdraw button click
private void OpnemenButton_Click(object sender, EventArgs e)
{
try
@@ -183,6 +201,7 @@ public class MainForm : Form
}
}
// Event handler for transaction history button click
private void TransactieGeschiedenisButton_Click(object sender, EventArgs e)
{
var transactieGeschiedenis = mijnRekening.GetTransactieGeschiedenis();
@@ -199,6 +218,7 @@ public class MainForm : Form
#endregion
#region Program Class
// Main program class
class Program
{
static void Main()

View File

@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Bankrekening")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+5e6c6efc697d9a0c8209d4793c99631010f6dfe1")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+fd28e1a375b6eae866ea0240eaf196c1223efab2")]
[assembly: System.Reflection.AssemblyProductAttribute("Bankrekening")]
[assembly: System.Reflection.AssemblyTitleAttribute("Bankrekening")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@@ -1 +1 @@
1d1a27639a7c88a12eb16c69957f88f21fc766224101c919ae4d0eb231f9dc10
0c34e76bda4e4d6e48fb3434c0cdb52fb67f3cfdd67f8a9433843c2f79e2732d

View File

@@ -1 +1 @@
{"documents":{"C:\\Users\\steen\\Desktop\\Alvin\\ict-algemeen-opdrachten\\*":"https://raw.githubusercontent.com/Alvin-Zilverstand/ict-algemeen-opdrachten/5e6c6efc697d9a0c8209d4793c99631010f6dfe1/*"}}
{"documents":{"C:\\Users\\steen\\Desktop\\Alvin\\ict-algemeen-opdrachten\\*":"https://raw.githubusercontent.com/Alvin-Zilverstand/ict-algemeen-opdrachten/fd28e1a375b6eae866ea0240eaf196c1223efab2/*"}}