mirror of
https://github.com/Alvin-Zilverstand/ict-algemeen-opdrachten.git
synced 2026-03-06 11:06:59 +01:00
Translate user prompts and comments to Dutch; delete unused weather log file
This commit is contained in:
@@ -3,24 +3,23 @@ using System.Collections.Generic;
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
// Class representing a bank account
|
|
||||||
class Bankrekening
|
class Bankrekening
|
||||||
{
|
{
|
||||||
public string Rekeningnummer { get; }
|
public string Rekeningnummer { get; }
|
||||||
private decimal saldo;
|
private decimal saldo;
|
||||||
private List<Transactie> transacties;
|
private List<Transactie> transacties;
|
||||||
|
|
||||||
// Constructor to initialize account number and starting balance
|
|
||||||
public Bankrekening(string rekeningnummer, decimal beginsaldo)
|
public Bankrekening(string rekeningnummer, decimal beginsaldo)
|
||||||
{
|
{
|
||||||
|
// Initialiseer rekeningnummer en beginsaldo
|
||||||
Rekeningnummer = rekeningnummer;
|
Rekeningnummer = rekeningnummer;
|
||||||
saldo = beginsaldo;
|
saldo = beginsaldo;
|
||||||
transacties = new List<Transactie>();
|
transacties = new List<Transactie>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to deposit money into the account with a description
|
|
||||||
public void Storten(decimal bedrag, string beschrijving)
|
public void Storten(decimal bedrag, string beschrijving)
|
||||||
{
|
{
|
||||||
|
// Stort geld op de rekening met een beschrijving
|
||||||
if (bedrag > 0)
|
if (bedrag > 0)
|
||||||
{
|
{
|
||||||
saldo += bedrag;
|
saldo += bedrag;
|
||||||
@@ -28,13 +27,13 @@ class Bankrekening
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new ArgumentException("The amount must be positive.");
|
throw new ArgumentException("Het bedrag moet positief zijn.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to withdraw money from the account with a description
|
|
||||||
public void Opnemen(decimal bedrag, string beschrijving)
|
public void Opnemen(decimal bedrag, string beschrijving)
|
||||||
{
|
{
|
||||||
|
// Neem geld op van de rekening met een beschrijving
|
||||||
if (bedrag > 0 && bedrag <= saldo)
|
if (bedrag > 0 && bedrag <= saldo)
|
||||||
{
|
{
|
||||||
saldo -= bedrag;
|
saldo -= bedrag;
|
||||||
@@ -42,40 +41,38 @@ class Bankrekening
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new ArgumentException("Insufficient balance or invalid amount.");
|
throw new ArgumentException("Onvoldoende saldo of ongeldig bedrag.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to check the current balance
|
|
||||||
public decimal ControleerSaldo()
|
public decimal ControleerSaldo()
|
||||||
{
|
{
|
||||||
|
// Controleer het huidige saldo
|
||||||
return saldo;
|
return saldo;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to get the transaction history
|
|
||||||
public List<Transactie> GetTransactieGeschiedenis()
|
public List<Transactie> GetTransactieGeschiedenis()
|
||||||
{
|
{
|
||||||
|
// Haal de transactiegeschiedenis op
|
||||||
return transacties;
|
return transacties;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Class representing a transaction
|
|
||||||
class Transactie
|
class Transactie
|
||||||
{
|
{
|
||||||
public decimal Bedrag { get; }
|
public decimal Bedrag { get; }
|
||||||
public string Beschrijving { get; }
|
public string Beschrijving { get; }
|
||||||
public DateTime Datum { get; }
|
public DateTime Datum { get; }
|
||||||
|
|
||||||
// Constructor to initialize transaction details
|
|
||||||
public Transactie(decimal bedrag, string beschrijving)
|
public Transactie(decimal bedrag, string beschrijving)
|
||||||
{
|
{
|
||||||
|
// Initialiseer transactiegegevens
|
||||||
Bedrag = bedrag;
|
Bedrag = bedrag;
|
||||||
Beschrijving = beschrijving;
|
Beschrijving = beschrijving;
|
||||||
Datum = DateTime.Now;
|
Datum = DateTime.Now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main form for the application
|
|
||||||
public class MainForm : Form
|
public class MainForm : Form
|
||||||
{
|
{
|
||||||
private Bankrekening mijnRekening;
|
private Bankrekening mijnRekening;
|
||||||
@@ -86,9 +83,9 @@ public class MainForm : Form
|
|||||||
private Button opnemenButton;
|
private Button opnemenButton;
|
||||||
private Button transactieGeschiedenisButton;
|
private Button transactieGeschiedenisButton;
|
||||||
|
|
||||||
// Constructor to initialize the form and its controls
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
|
// Initialiseer de GUI-componenten
|
||||||
mijnRekening = new Bankrekening("NL01BANK0123456789", 1000);
|
mijnRekening = new Bankrekening("NL01BANK0123456789", 1000);
|
||||||
|
|
||||||
saldoLabel = new Label()
|
saldoLabel = new Label()
|
||||||
@@ -111,7 +108,7 @@ public class MainForm : Form
|
|||||||
BackColor = Color.White,
|
BackColor = Color.White,
|
||||||
ForeColor = Color.Black,
|
ForeColor = Color.Black,
|
||||||
BorderStyle = BorderStyle.FixedSingle,
|
BorderStyle = BorderStyle.FixedSingle,
|
||||||
PlaceholderText = "Amount"
|
PlaceholderText = "Bedrag"
|
||||||
};
|
};
|
||||||
beschrijvingTextBox = new TextBox()
|
beschrijvingTextBox = new TextBox()
|
||||||
{
|
{
|
||||||
@@ -122,11 +119,11 @@ public class MainForm : Form
|
|||||||
BackColor = Color.White,
|
BackColor = Color.White,
|
||||||
ForeColor = Color.Black,
|
ForeColor = Color.Black,
|
||||||
BorderStyle = BorderStyle.FixedSingle,
|
BorderStyle = BorderStyle.FixedSingle,
|
||||||
PlaceholderText = "Description"
|
PlaceholderText = "Beschrijving"
|
||||||
};
|
};
|
||||||
stortenButton = new Button()
|
stortenButton = new Button()
|
||||||
{
|
{
|
||||||
Text = "Deposit",
|
Text = "Storten",
|
||||||
Top = 140,
|
Top = 140,
|
||||||
Left = 20,
|
Left = 20,
|
||||||
Width = 260,
|
Width = 260,
|
||||||
@@ -138,7 +135,7 @@ public class MainForm : Form
|
|||||||
};
|
};
|
||||||
opnemenButton = new Button()
|
opnemenButton = new Button()
|
||||||
{
|
{
|
||||||
Text = "Withdraw",
|
Text = "Opnemen",
|
||||||
Top = 200,
|
Top = 200,
|
||||||
Left = 20,
|
Left = 20,
|
||||||
Width = 260,
|
Width = 260,
|
||||||
@@ -150,7 +147,7 @@ public class MainForm : Form
|
|||||||
};
|
};
|
||||||
transactieGeschiedenisButton = new Button()
|
transactieGeschiedenisButton = new Button()
|
||||||
{
|
{
|
||||||
Text = "Transaction History",
|
Text = "Transactiegeschiedenis",
|
||||||
Top = 260,
|
Top = 260,
|
||||||
Left = 20,
|
Left = 20,
|
||||||
Width = 260,
|
Width = 260,
|
||||||
@@ -172,15 +169,15 @@ public class MainForm : Form
|
|||||||
Controls.Add(opnemenButton);
|
Controls.Add(opnemenButton);
|
||||||
Controls.Add(transactieGeschiedenisButton);
|
Controls.Add(transactieGeschiedenisButton);
|
||||||
|
|
||||||
Text = "Bank Account Management";
|
Text = "Bankrekening Beheer";
|
||||||
Size = new Size(320, 380);
|
Size = new Size(320, 380);
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
BackColor = Color.White;
|
BackColor = Color.White;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event handler for deposit button click
|
|
||||||
private void StortenButton_Click(object sender, EventArgs e)
|
private void StortenButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
// Verwerk de storting
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
decimal bedrag = decimal.Parse(bedragTextBox.Text);
|
decimal bedrag = decimal.Parse(bedragTextBox.Text);
|
||||||
@@ -194,9 +191,9 @@ public class MainForm : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event handler for withdraw button click
|
|
||||||
private void OpnemenButton_Click(object sender, EventArgs e)
|
private void OpnemenButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
// Verwerk de opname
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
decimal bedrag = decimal.Parse(bedragTextBox.Text);
|
decimal bedrag = decimal.Parse(bedragTextBox.Text);
|
||||||
@@ -210,12 +207,12 @@ public class MainForm : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event handler for transaction history button click
|
|
||||||
private void TransactieGeschiedenisButton_Click(object sender, EventArgs e)
|
private void TransactieGeschiedenisButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
// Toon de transactiegeschiedenis
|
||||||
var transactieGeschiedenis = mijnRekening.GetTransactieGeschiedenis();
|
var transactieGeschiedenis = mijnRekening.GetTransactieGeschiedenis();
|
||||||
string geschiedenis = "Transaction History:\n";
|
string geschiedenis = "Transactiegeschiedenis:\n";
|
||||||
geschiedenis += "Date\t\tDescription\t\tAmount\n";
|
geschiedenis += "Datum\t\tBeschrijving\t\tBedrag\n";
|
||||||
geschiedenis += "---------------------------------------------\n";
|
geschiedenis += "---------------------------------------------\n";
|
||||||
foreach (var transactie in transactieGeschiedenis)
|
foreach (var transactie in transactieGeschiedenis)
|
||||||
{
|
{
|
||||||
@@ -225,16 +222,16 @@ public class MainForm : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main program class
|
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
|
// Start de applicatie
|
||||||
var mijnRekening = new Bankrekening("NL01BANK0123456789", 1000);
|
var mijnRekening = new Bankrekening("NL01BANK0123456789", 1000);
|
||||||
mijnRekening.Storten(100.00m, "Initial deposit");
|
mijnRekening.Storten(100.00m, "Initial deposit");
|
||||||
mijnRekening.Opnemen(50.00m, "ATM withdrawal");
|
mijnRekening.Opnemen(50.00m, "ATM withdrawal");
|
||||||
|
|
||||||
Console.WriteLine("Transaction History:");
|
Console.WriteLine("Transactiegeschiedenis:");
|
||||||
foreach (var transactie in mijnRekening.GetTransactieGeschiedenis())
|
foreach (var transactie in mijnRekening.GetTransactieGeschiedenis())
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{transactie.Datum}: {transactie.Beschrijving} - {transactie.Bedrag:C}");
|
Console.WriteLine($"{transactie.Datum}: {transactie.Beschrijving} - {transactie.Bedrag:C}");
|
||||||
|
|||||||
@@ -4,21 +4,21 @@ class Program
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
// Ask the user to enter the first number
|
// Vraag de gebruiker om het eerste getal in te voeren
|
||||||
Console.WriteLine("Enter the first number:");
|
Console.WriteLine("Voer het eerste getal in:");
|
||||||
double num1 = Convert.ToDouble(Console.ReadLine());
|
double num1 = Convert.ToDouble(Console.ReadLine());
|
||||||
|
|
||||||
// Ask the user to enter an operator (+, -, *, /)
|
// Vraag de gebruiker om een operator in te voeren (+, -, *, /)
|
||||||
Console.WriteLine("Enter an operator (+, -, *, /):");
|
Console.WriteLine("Voer een operator in (+, -, *, /):");
|
||||||
string op = Console.ReadLine();
|
string op = Console.ReadLine();
|
||||||
|
|
||||||
// Ask the user to enter the second number
|
// Vraag de gebruiker om het tweede getal in te voeren
|
||||||
Console.WriteLine("Enter the second number:");
|
Console.WriteLine("Voer het tweede getal in:");
|
||||||
double num2 = Convert.ToDouble(Console.ReadLine());
|
double num2 = Convert.ToDouble(Console.ReadLine());
|
||||||
|
|
||||||
double result = 0;
|
double result = 0;
|
||||||
|
|
||||||
// Perform the operation based on the entered operator
|
// Voer de bewerking uit op basis van de ingevoerde operator
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case "+":
|
case "+":
|
||||||
@@ -37,18 +37,18 @@ class Program
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Display an error message if attempting to divide by zero
|
// Toon een foutmelding bij poging tot delen door nul
|
||||||
Console.WriteLine("Cannot divide by zero.");
|
Console.WriteLine("Kan niet delen door nul.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Display an error message if the entered operator is invalid
|
// Toon een foutmelding bij een ongeldige operator
|
||||||
Console.WriteLine("Invalid operator.");
|
Console.WriteLine("Ongeldige operator.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the result of the calculation
|
// Toon het resultaat van de berekening
|
||||||
Console.WriteLine("The result is: " + result);
|
Console.WriteLine("Het resultaat is: " + result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,39 +16,39 @@ class Program : Form
|
|||||||
|
|
||||||
public Program()
|
public Program()
|
||||||
{
|
{
|
||||||
// Initialize the random number to guess
|
// Initialiseer het te raden getal
|
||||||
numberToGuess = random.Next(1, 101);
|
numberToGuess = random.Next(1, 101);
|
||||||
|
|
||||||
// Set up the form
|
// Stel het formulier in
|
||||||
this.Text = "Gokspel";
|
this.Text = "Gokspel";
|
||||||
this.Size = new System.Drawing.Size(300, 200);
|
this.Size = new System.Drawing.Size(300, 200);
|
||||||
|
|
||||||
// Create and add the prompt label
|
// Maak en voeg het promptlabel toe
|
||||||
Label promptLabel = new Label();
|
Label promptLabel = new Label();
|
||||||
promptLabel.Text = "Raad het getal tussen 1 en 100:";
|
promptLabel.Text = "Raad het getal tussen 1 en 100:";
|
||||||
promptLabel.Location = new System.Drawing.Point(10, 20);
|
promptLabel.Location = new System.Drawing.Point(10, 20);
|
||||||
promptLabel.AutoSize = true;
|
promptLabel.AutoSize = true;
|
||||||
this.Controls.Add(promptLabel);
|
this.Controls.Add(promptLabel);
|
||||||
|
|
||||||
// Create and add the input box
|
// Maak en voeg het invoervak toe
|
||||||
inputBox = new TextBox();
|
inputBox = new TextBox();
|
||||||
inputBox.Location = new System.Drawing.Point(10, 50);
|
inputBox.Location = new System.Drawing.Point(10, 50);
|
||||||
this.Controls.Add(inputBox);
|
this.Controls.Add(inputBox);
|
||||||
|
|
||||||
// Create and add the guess button
|
// Maak en voeg de gokknop toe
|
||||||
guessButton = new Button();
|
guessButton = new Button();
|
||||||
guessButton.Text = "Gok";
|
guessButton.Text = "Gok";
|
||||||
guessButton.Location = new System.Drawing.Point(10, 80);
|
guessButton.Location = new System.Drawing.Point(10, 80);
|
||||||
guessButton.Click += new EventHandler(GuessButton_Click);
|
guessButton.Click += new EventHandler(GuessButton_Click);
|
||||||
this.Controls.Add(guessButton);
|
this.Controls.Add(guessButton);
|
||||||
|
|
||||||
// Create and add the result label
|
// Maak en voeg het resultaatlabel toe
|
||||||
resultLabel = new Label();
|
resultLabel = new Label();
|
||||||
resultLabel.Location = new System.Drawing.Point(10, 110);
|
resultLabel.Location = new System.Drawing.Point(10, 110);
|
||||||
resultLabel.AutoSize = true;
|
resultLabel.AutoSize = true;
|
||||||
this.Controls.Add(resultLabel);
|
this.Controls.Add(resultLabel);
|
||||||
|
|
||||||
// Create and add the restart button (initially hidden)
|
// Maak en voeg de herstartknop toe (aanvankelijk verborgen)
|
||||||
restartButton = new Button();
|
restartButton = new Button();
|
||||||
restartButton.Text = "Opnieuw";
|
restartButton.Text = "Opnieuw";
|
||||||
restartButton.Location = new System.Drawing.Point(10, 140);
|
restartButton.Location = new System.Drawing.Point(10, 140);
|
||||||
@@ -56,7 +56,7 @@ class Program : Form
|
|||||||
restartButton.Visible = false;
|
restartButton.Visible = false;
|
||||||
this.Controls.Add(restartButton);
|
this.Controls.Add(restartButton);
|
||||||
|
|
||||||
// Set up the confetti timer
|
// Stel de confetti-timer in
|
||||||
confettiTimer = new System.Windows.Forms.Timer();
|
confettiTimer = new System.Windows.Forms.Timer();
|
||||||
confettiTimer.Interval = 30;
|
confettiTimer.Interval = 30;
|
||||||
confettiTimer.Tick += new EventHandler(ConfettiTimer_Tick);
|
confettiTimer.Tick += new EventHandler(ConfettiTimer_Tick);
|
||||||
@@ -64,45 +64,46 @@ class Program : Form
|
|||||||
|
|
||||||
private void GuessButton_Click(object sender, EventArgs e)
|
private void GuessButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
// Verwerk de gok van de gebruiker
|
||||||
int userGuess;
|
int userGuess;
|
||||||
if (int.TryParse(inputBox.Text, out userGuess))
|
if (int.TryParse(inputBox.Text, out userGuess))
|
||||||
{
|
{
|
||||||
if (userGuess < numberToGuess)
|
if (userGuess < numberToGuess)
|
||||||
{
|
{
|
||||||
resultLabel.Text = "Too low! Try again.";
|
resultLabel.Text = "Te laag! Probeer opnieuw.";
|
||||||
}
|
}
|
||||||
else if (userGuess > numberToGuess)
|
else if (userGuess > numberToGuess)
|
||||||
{
|
{
|
||||||
resultLabel.Text = "Too high! Try again.";
|
resultLabel.Text = "Te hoog! Probeer opnieuw.";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
resultLabel.Text = "Congratulations! You guessed the correct number.";
|
resultLabel.Text = "Gefeliciteerd! Je hebt het juiste getal geraden.";
|
||||||
StartConfetti();
|
StartConfetti();
|
||||||
restartButton.Visible = true; // Show the restart button
|
restartButton.Visible = true; // Toon de herstartknop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
resultLabel.Text = "Invalid input. Please enter a number.";
|
resultLabel.Text = "Ongeldige invoer. Voer een getal in.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RestartButton_Click(object sender, EventArgs e)
|
private void RestartButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Reset the game
|
// Reset het spel
|
||||||
numberToGuess = random.Next(1, 101);
|
numberToGuess = random.Next(1, 101);
|
||||||
resultLabel.Text = "";
|
resultLabel.Text = "";
|
||||||
inputBox.Text = "";
|
inputBox.Text = "";
|
||||||
confettiList.Clear();
|
confettiList.Clear();
|
||||||
confettiTimer.Stop();
|
confettiTimer.Stop();
|
||||||
restartButton.Visible = false; // Hide the restart button
|
restartButton.Visible = false; // Verberg de herstartknop
|
||||||
this.Invalidate();
|
this.Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void StartConfetti()
|
private void StartConfetti()
|
||||||
{
|
{
|
||||||
// Initialize confetti
|
// Initialiseer confetti
|
||||||
confettiList.Clear();
|
confettiList.Clear();
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
{
|
{
|
||||||
@@ -113,7 +114,7 @@ class Program : Form
|
|||||||
|
|
||||||
private void ConfettiTimer_Tick(object sender, EventArgs e)
|
private void ConfettiTimer_Tick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Update confetti positions
|
// Update de posities van de confetti
|
||||||
for (int i = 0; i < confettiList.Count; i++)
|
for (int i = 0; i < confettiList.Count; i++)
|
||||||
{
|
{
|
||||||
confettiList[i].Update();
|
confettiList[i].Update();
|
||||||
@@ -124,7 +125,7 @@ class Program : Form
|
|||||||
protected override void OnPaint(PaintEventArgs e)
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnPaint(e);
|
base.OnPaint(e);
|
||||||
// Draw confetti
|
// Teken de confetti
|
||||||
foreach (var confetti in confettiList)
|
foreach (var confetti in confettiList)
|
||||||
{
|
{
|
||||||
e.Graphics.FillEllipse(new SolidBrush(confetti.Color), confetti.Position.X, confetti.Position.Y, confetti.Size, confetti.Size);
|
e.Graphics.FillEllipse(new SolidBrush(confetti.Color), confetti.Position.X, confetti.Position.Y, confetti.Size, confetti.Size);
|
||||||
@@ -134,6 +135,7 @@ class Program : Form
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
|
// Start de applicatie
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.Run(new Program());
|
Application.Run(new Program());
|
||||||
}
|
}
|
||||||
@@ -149,7 +151,7 @@ class Confetti
|
|||||||
|
|
||||||
public Confetti(Random random, Size clientSize)
|
public Confetti(Random random, Size clientSize)
|
||||||
{
|
{
|
||||||
// Initialize confetti properties
|
// Initialiseer de eigenschappen van de confetti
|
||||||
Position = new PointF(random.Next(clientSize.Width), random.Next(clientSize.Height));
|
Position = new PointF(random.Next(clientSize.Width), random.Next(clientSize.Height));
|
||||||
SpeedY = (float)(random.NextDouble() * 2 + 1);
|
SpeedY = (float)(random.NextDouble() * 2 + 1);
|
||||||
SpeedX = (float)(random.NextDouble() * 2 - 1);
|
SpeedX = (float)(random.NextDouble() * 2 - 1);
|
||||||
@@ -159,8 +161,8 @@ class Confetti
|
|||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
// Update confetti position and apply gravity
|
// Update de positie van de confetti en pas zwaartekracht toe
|
||||||
Position = new PointF(Position.X + SpeedX, Position.Y + SpeedY);
|
Position = new PointF(Position.X + SpeedX, Position.Y + SpeedY);
|
||||||
SpeedY += 0.1f; // gravity effect
|
SpeedY += 0.1f; // zwaartekracht effect
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,8 +15,9 @@ namespace DictionaryApp
|
|||||||
|
|
||||||
public Program()
|
public Program()
|
||||||
{
|
{
|
||||||
|
// Initialiseer de GUI-componenten
|
||||||
wordTextBox = new TextBox { Left = 50, Top = 20, Width = 200 };
|
wordTextBox = new TextBox { Left = 50, Top = 20, Width = 200 };
|
||||||
searchButton = new Button { Text = "Search", Left = 260, Top = 20, Width = 100 };
|
searchButton = new Button { Text = "Zoek", Left = 260, Top = 20, Width = 100 };
|
||||||
meaningTextBox = new TextBox { Left = 50, Top = 60, Width = 310, Height = 200, Multiline = true, ScrollBars = ScrollBars.Vertical, ReadOnly = true };
|
meaningTextBox = new TextBox { Left = 50, Top = 60, Width = 310, Height = 200, Multiline = true, ScrollBars = ScrollBars.Vertical, ReadOnly = true };
|
||||||
|
|
||||||
searchButton.Click += new EventHandler(SearchButton_Click);
|
searchButton.Click += new EventHandler(SearchButton_Click);
|
||||||
@@ -27,42 +28,45 @@ namespace DictionaryApp
|
|||||||
Controls.Add(searchButton);
|
Controls.Add(searchButton);
|
||||||
Controls.Add(meaningTextBox);
|
Controls.Add(meaningTextBox);
|
||||||
|
|
||||||
Text = "Dictionary";
|
Text = "Woordenboek";
|
||||||
Size = new System.Drawing.Size(400, 300);
|
Size = new System.Drawing.Size(400, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Form_Resize(object? sender, EventArgs e)
|
private void Form_Resize(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
// Pas de grootte van het tekstvak aan bij het wijzigen van de grootte van het formulier
|
||||||
meaningTextBox.Width = this.ClientSize.Width - 100;
|
meaningTextBox.Width = this.ClientSize.Width - 100;
|
||||||
meaningTextBox.Height = this.ClientSize.Height - 100;
|
meaningTextBox.Height = this.ClientSize.Height - 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WordTextBox_KeyDown(object? sender, KeyEventArgs e)
|
private void WordTextBox_KeyDown(object? sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
|
// Zoek bij het indrukken van de Enter-toets
|
||||||
if (e.KeyCode == Keys.Enter)
|
if (e.KeyCode == Keys.Enter)
|
||||||
{
|
{
|
||||||
SearchButton_Click(this, new EventArgs());
|
SearchButton_Click(this, new EventArgs());
|
||||||
e.SuppressKeyPress = true; // Prevent the beep sound on Enter key press
|
e.SuppressKeyPress = true; // Voorkom het piepgeluid bij het indrukken van de Enter-toets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void SearchButton_Click(object? sender, EventArgs e)
|
private async void SearchButton_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
// Haal de betekenis van het woord op van de API
|
||||||
string word = wordTextBox.Text;
|
string word = wordTextBox.Text;
|
||||||
string? meaning = await GetMeaningFromApi(word);
|
string? meaning = await GetMeaningFromApi(word);
|
||||||
meaningTextBox.Text = meaning ?? "Meaning not found.";
|
meaningTextBox.Text = meaning ?? "Betekenis niet gevonden.";
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<string?> GetMeaningFromApi(string word)
|
private async Task<string?> GetMeaningFromApi(string word)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Maak een verzoek naar de woordenboek-API
|
||||||
string apiUrl = $"https://api.dictionaryapi.dev/api/v2/entries/en/{word}";
|
string apiUrl = $"https://api.dictionaryapi.dev/api/v2/entries/en/{word}";
|
||||||
HttpResponseMessage response = await client.GetAsync(apiUrl);
|
HttpResponseMessage response = await client.GetAsync(apiUrl);
|
||||||
response.EnsureSuccessStatusCode();
|
response.EnsureSuccessStatusCode();
|
||||||
string responseBody = await response.Content.ReadAsStringAsync();
|
string responseBody = await response.Content.ReadAsStringAsync();
|
||||||
// Parse the responseBody to extract the meaning
|
// Parse de JSON-respons om de betekenis te extraheren
|
||||||
// This is a simplified example, you may need to adjust the parsing based on the actual API response format
|
|
||||||
var json = System.Text.Json.JsonDocument.Parse(responseBody);
|
var json = System.Text.Json.JsonDocument.Parse(responseBody);
|
||||||
var meaning = json.RootElement[0].GetProperty("meanings")[0].GetProperty("definitions")[0].GetProperty("definition").GetString();
|
var meaning = json.RootElement[0].GetProperty("meanings")[0].GetProperty("definitions")[0].GetProperty("definition").GetString();
|
||||||
return meaning;
|
return meaning;
|
||||||
@@ -76,6 +80,7 @@ namespace DictionaryApp
|
|||||||
[STAThread]
|
[STAThread]
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
|
// Start de applicatie
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
Application.Run(new Program());
|
Application.Run(new Program());
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
|
|
||||||
Weer op coördinaten (50.8876735, 5.9773285) in Heerlen:
|
|
||||||
Temperatuur: 7.48°C
|
|
||||||
Weer: clear sky
|
|
||||||
Reference in New Issue
Block a user