Skip to content

Commit

Permalink
N26 Hometask is mark done
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdurahmon0412 committed Aug 18, 2023
1 parent b19b4ec commit d72a25e
Show file tree
Hide file tree
Showing 11 changed files with 221 additions and 2 deletions.
3 changes: 2 additions & 1 deletion HT_N25/Services/ProductService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ topilmasa exception

public List<IProduct> Get(ProductFilterDataModel filter)
{
var filterProducts = _inventories.Where(item => filter.ProductTypes.Contains(item.GetType().FullName)).ToList();
var filterProducts = _inventories.Where(item =>
filter.ProductTypes.Contains(item.GetType().FullName)).ToList();
var result = new List<IProduct>(filterProducts);
return result;
}
Expand Down
18 changes: 17 additions & 1 deletion Homeworks.sln
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "N24_HT1", "N23_HT24\N24_HT1
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "N25", "N25", "{F9C8D322-69BC-4757-A70E-E3593F8DD840}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HT_N25", "HT_N25\HT_N25.csproj", "{71BD1DED-EDCA-46DE-ABFD-BDC682E26100}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HT_N25", "HT_N25\HT_N25.csproj", "{71BD1DED-EDCA-46DE-ABFD-BDC682E26100}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "N26", "N26", "{19A44840-2DDD-4E39-BF10-AF0DB85A9CBE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "N26_HT1", "N26_HT1\N26_HT1.csproj", "{050A82DA-46BF-4FB9-910C-85849FDECDE9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "N26_HT2", "N26_HT2\N26_HT2.csproj", "{C178D0BF-BD12-4985-B3E1-512E6AAAFC54}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -375,6 +381,14 @@ Global
{71BD1DED-EDCA-46DE-ABFD-BDC682E26100}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71BD1DED-EDCA-46DE-ABFD-BDC682E26100}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71BD1DED-EDCA-46DE-ABFD-BDC682E26100}.Release|Any CPU.Build.0 = Release|Any CPU
{050A82DA-46BF-4FB9-910C-85849FDECDE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{050A82DA-46BF-4FB9-910C-85849FDECDE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{050A82DA-46BF-4FB9-910C-85849FDECDE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{050A82DA-46BF-4FB9-910C-85849FDECDE9}.Release|Any CPU.Build.0 = Release|Any CPU
{C178D0BF-BD12-4985-B3E1-512E6AAAFC54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C178D0BF-BD12-4985-B3E1-512E6AAAFC54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C178D0BF-BD12-4985-B3E1-512E6AAAFC54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C178D0BF-BD12-4985-B3E1-512E6AAAFC54}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -450,6 +464,8 @@ Global
{436DDA7F-BCFF-4A0A-8C40-AFF08569297B} = {BC687718-A58E-4FE8-843D-A519D0CBE24B}
{426A261F-A5DE-4783-A304-09AE82965733} = {2546A077-DCDE-4476-A4B4-78B389A17604}
{71BD1DED-EDCA-46DE-ABFD-BDC682E26100} = {F9C8D322-69BC-4757-A70E-E3593F8DD840}
{050A82DA-46BF-4FB9-910C-85849FDECDE9} = {19A44840-2DDD-4E39-BF10-AF0DB85A9CBE}
{C178D0BF-BD12-4985-B3E1-512E6AAAFC54} = {19A44840-2DDD-4E39-BF10-AF0DB85A9CBE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8B77269B-B20D-4860-9637-2E2771096EE6}
Expand Down
15 changes: 15 additions & 0 deletions N26_HT1/Enums/Currency.cs
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
}
}
14 changes: 14 additions & 0 deletions N26_HT1/Enums/MoneyType.cs
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
}
}
53 changes: 53 additions & 0 deletions N26_HT1/Money.cs
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;
}
}
}
10 changes: 10 additions & 0 deletions N26_HT1/N26_HT1.csproj
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>
43 changes: 43 additions & 0 deletions N26_HT1/Program.cs
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));
16 changes: 16 additions & 0 deletions N26_HT2/Enums/SkillLevels.cs
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
}
}
10 changes: 10 additions & 0 deletions N26_HT2/N26_HT2.csproj
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>
17 changes: 17 additions & 0 deletions N26_HT2/Program.cs
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 )
24 changes: 24 additions & 0 deletions N26_HT2/Skills.cs
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;
}
}
}

1 comment on commit d72a25e

@Abdurahmon0412
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ajoyib ish

Please sign in to comment.