-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b19b4ec
commit d72a25e
Showing
11 changed files
with
221 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace N26_HT1.Enums | ||
{ | ||
public enum Currency | ||
{ | ||
UZS, | ||
USD, | ||
RUB | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace N26_HT1.Enums | ||
{ | ||
public enum MoneyType | ||
{ | ||
InBalance, | ||
Loan | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using N26_HT1.Enums; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace N26_HT1 | ||
{ | ||
public class Money | ||
{ | ||
public decimal Amount { get; set; } | ||
public MoneyType Type { get; set; } | ||
public Currency Currency { get; set; } | ||
|
||
public Money(decimal amount, MoneyType type, Currency currency = Currency.UZS) | ||
{ | ||
Amount = amount; | ||
Type = type; | ||
Currency = currency; | ||
} | ||
public Money() | ||
{ | ||
} | ||
|
||
//+ operatsiyasi uchun : | ||
|
||
//-moneyA va moneyB bir xil tipda bo'lsa - qo'shiladi | ||
//- moneyA in balance va moneyB loan bo'lsa - moneyA - moneyB qilinadi | ||
//- moneyB loan va moneyB in balance bo'lsa - moneyB - moneyA qilinadi | ||
public static Money operator + (Money moneyA, Money moneyB) | ||
{ | ||
if (moneyA.Type == moneyB.Type) | ||
return new Money(moneyA.Convert(moneyA) + moneyB.Convert(moneyB), moneyA.Type); | ||
if (moneyA.Type == MoneyType.InBalance && moneyB.Type == MoneyType.Loan) | ||
return new Money(moneyA.Convert(moneyA) - moneyB.Convert(moneyB), moneyA.Type); | ||
if (moneyA.Type == MoneyType.Loan && moneyB.Type == MoneyType.InBalance) | ||
return new Money( moneyB.Convert(moneyB) - moneyA.Convert(moneyA), moneyA.Type); | ||
return null; | ||
} | ||
|
||
public decimal Convert(Money money) | ||
{ | ||
if (money.Currency.ToString() == "UZS") | ||
return money.Amount; | ||
if(money.Currency.ToString() == "USD") | ||
return money.Amount * 12000; | ||
if (money.Currency.ToString() == "RUB") | ||
return money.Amount * 129; | ||
else return 0; | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//unda + va - operatorlarini overload qiling, | ||
//bunda MoneyType dan kelib chiqib amal bajarilsin, masalan moneyA va moneyB bor deylik | ||
|
||
//+ operatsiyasi uchun : | ||
|
||
//-moneyA va moneyB bir xil tipda bo'lsa - qo'shiladi | ||
//- moneyA in balance va moneyB loan bo'lsa - moneyA - moneyB qilinadi | ||
//- moneyB loan va moneyB in balance bo'lsa - moneyB - moneyA qilinadi | ||
|
||
//- Money tipidagi kolleksiyaga bir nechta object qo'shing | ||
//- ular orasida qarzlar ham bo'lsin | ||
//- hammasini qo'shib ekranga chiqaring | ||
|
||
//PS : bunda konversiyalarni o'g'irish uchun Convert methodidan foydalanish mumkin | ||
|
||
//Fake data : | ||
|
||
using N26_HT1; | ||
using N26_HT1.Enums; | ||
|
||
List<Money> moneyList = new List<Money> | ||
{ | ||
new Money { Amount = 100.00m, Type = MoneyType.InBalance, Currency = Currency.UZS }, | ||
new Money { Amount = 50.00m, Type = MoneyType.InBalance, Currency = Currency.USD }, | ||
new Money { Amount = 200.00m, Type = MoneyType.Loan, Currency = Currency.RUB }, | ||
new Money { Amount = 75.00m, Type = MoneyType.InBalance, Currency = Currency.UZS }, | ||
new Money { Amount = 150.00m, Type = MoneyType.Loan, Currency = Currency.USD }, | ||
new Money { Amount = 25.00m, Type = MoneyType.InBalance, Currency = Currency.RUB }, | ||
new Money { Amount = 50.00m, Type = MoneyType.InBalance, Currency = Currency.USD}, | ||
new Money { Amount = 10.00m, Type = MoneyType.Loan, Currency = Currency.UZS }, | ||
new Money { Amount = 5.00m, Type = MoneyType.Loan, Currency = Currency.RUB }, | ||
new Money { Amount = 100.00m, Type = MoneyType.InBalance, Currency = Currency.UZS } | ||
}; | ||
|
||
var TotalMoney = new Money { Amount = 0, Type = MoneyType.InBalance,Currency = Currency.UZS}; | ||
|
||
foreach (var money in moneyList) | ||
{ | ||
TotalMoney = TotalMoney + money; | ||
} | ||
|
||
Console.WriteLine($"Total amount = {TotalMoney.Amount} {TotalMoney.Currency}"); | ||
//Console.WriteLine(moneyList.Sum(sum => sum.Amount)); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace N26_HT2.Enums | ||
{ | ||
public enum SkillLevels | ||
{ | ||
Beginner, | ||
Experienced, | ||
Master, | ||
Expert | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
| ||
|
||
|
||
|
||
|
||
//- Skill modelidan foydalaning(id, name, level ) | ||
|
||
//CollectionExtensions static modelidan ( class ) foydalaning | ||
|
||
//unda quyidagi extension methodlar bo'lsin | ||
|
||
//- Update ( this ICollection<Skill> first, ICollection<Skill> second ) | ||
|
||
//bunda first kolleksiyadan second kolleksiyadagi ichidan quyidagi turkumdagi itemlarni topib, amallar bajarish kerak | ||
//- added - qo'shilganlar ( second da bor, first da yo'q ) -bularni first ga qo'shish kerak | ||
//- removed - o'chirilganlar ( second da yo'q, first da bor ) -bularni first dan o'chirish kerak | ||
//- updated - o'zgartirilgan ( first da va second da bor va o'zgartirilgan ) -bularni first da update qilish kerak ( id dan tashqari ) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using N26_HT2.Enums; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace N26_HT2 | ||
{ | ||
public class Skills | ||
{ | ||
//- Skill modelidan foydalaning(id, name, level ) | ||
public int Id { get; set; } | ||
public string Name { get; set; } | ||
public SkillLevels Level { get; set; } | ||
|
||
public Skills(int id,string name, SkillLevels lavel) | ||
{ | ||
Id = id; | ||
Name = name; | ||
Level = lavel; | ||
} | ||
} | ||
} |
d72a25e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ajoyib ish