Created
July 2, 2025 23:25
-
-
Save Mirsalim3635/bcb3fc38aa10249b1ab034a4dbf32523 to your computer and use it in GitHub Desktop.
Lesson16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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