diff --git a/Lesson_4/Task_1/Customer.cs b/Lesson_4/Task_1/Customer.cs new file mode 100644 index 0000000..2ff3015 --- /dev/null +++ b/Lesson_4/Task_1/Customer.cs @@ -0,0 +1,59 @@ +namespace SingleResponsibility +{ + public class Customer + { + public int Id { get; set; } + public string Name { get; set; } + public decimal Balance { get; set; } + + public Customer(int id, string name, decimal balance) + { + Id = id; + Name = name; + Balance = balance; + } + + public void GetBalance() + { + Console.WriteLine($"Your balance is: {Balance}"); + } + } + + public class CustomerList + { + public List Customers = new List() + { + new Customer(1, "Fikus", 0), + new Customer(2, "VHarbar", 100000) + }; + + public decimal? GetBalanceById(int id) + { + var customer = Customers.FirstOrDefault(x => x.Id == id); + if (customer != null) + return customer.Balance; + else + return null; + } + + public Customer? GetById(int id) + { + return Customers.FirstOrDefault(x => x.Id == id); + } + + public void SaveToDatabase() + { + Console.WriteLine("Saved!"); + } + + public void UpdateBalance(int id, decimal newBalance) + { + var customer = GetById(id); + if (customer != null) + { + customer.Balance = newBalance; + SaveToDatabase(); + } + } + } +} diff --git a/Lesson_4/Task_1/Program.cs b/Lesson_4/Task_1/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/Lesson_4/Task_1/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/Lesson_4/Task_1/Task_1.csproj b/Lesson_4/Task_1/Task_1.csproj new file mode 100644 index 0000000..f02677b --- /dev/null +++ b/Lesson_4/Task_1/Task_1.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/Lesson_4/Task_2/MagicClass.cs b/Lesson_4/Task_2/MagicClass.cs new file mode 100644 index 0000000..84b4728 --- /dev/null +++ b/Lesson_4/Task_2/MagicClass.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Open_Closed +{ + public class FireMagic : Magic + { + public override void CountYourMagic() + { + Console.WriteLine("Wow, your magic is fire magic!"); + } + } + + public class WaterMagic : Magic + { + public override void CountYourMagic() + { + Console.WriteLine("Incredible! You have 50 millions of power! It's water magic!"); + } + } + + public class Magic + { + public virtual void CountYourMagic() + { + Console.WriteLine("I understand you..."); + } + } +} diff --git a/Lesson_4/Task_2/Program.cs b/Lesson_4/Task_2/Program.cs new file mode 100644 index 0000000..3751555 --- /dev/null +++ b/Lesson_4/Task_2/Program.cs @@ -0,0 +1,2 @@ +// See https://aka.ms/new-console-template for more information +Console.WriteLine("Hello, World!"); diff --git a/Lesson_4/Task_2/Task_2.csproj b/Lesson_4/Task_2/Task_2.csproj new file mode 100644 index 0000000..f02677b --- /dev/null +++ b/Lesson_4/Task_2/Task_2.csproj @@ -0,0 +1,10 @@ + + + + Exe + net7.0 + enable + enable + + + diff --git a/README.md b/README.md index e5a7c80..34d24f7 100644 --- a/README.md +++ b/README.md @@ -24,3 +24,8 @@ Checked means the task is Done. ### Lesson 3 - [x] Task 1 + +### Lesson 4 + +- [ ] Task 1 +- [ ] Task 2