Skip to content

Instantly share code, notes, and snippets.

@Mirsalim3635
Created July 2, 2025 23:25
Show Gist options
  • Select an option

  • Save Mirsalim3635/bcb3fc38aa10249b1ab034a4dbf32523 to your computer and use it in GitHub Desktop.

Select an option

Save Mirsalim3635/bcb3fc38aa10249b1ab034a4dbf32523 to your computer and use it in GitHub Desktop.
Lesson16
Console.Write(" Enter the price: ");
var price = int.Parse(Console.ReadLine() ?? "0");
Console.Write(" Enter the strstegy: ");
var namestrategy = Console.ReadLine()?.ToLower();
var strategies = new Dictionary<string, Func<double, double>>()
{
{ "none", p => p },
{ "vip", p => p * 0.8 },
{ "blackfriday", p => p * 0.5 }
};
if (strategies.ContainsKey(namestrategy))
{
Console.WriteLine(strategies[namestrategy](price));
}
else
Console.WriteLine("Strategy not found.");
public class BankAccount
{
public event EventHandler<decimal>? BalanceChanged;
private decimal balance;
public void Deposit(decimal amount)
{
balance += amount;
BalanceChanged?.Invoke(this, balance);
}
public void Withdraw(decimal amount)
{
if (balance >= amount)
{
balance -= amount;
BalanceChanged?.Invoke(this, balance);
}
else
{
Console.WriteLine("Insufficient funds.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment