Skip to content

Commit

Permalink
Home task same done
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdurahmon0412 committed Aug 3, 2023
1 parent c37f69e commit f7a9d63
Show file tree
Hide file tree
Showing 12 changed files with 239 additions and 2 deletions.
20 changes: 18 additions & 2 deletions Homeworks.sln
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "N16", "N16", "{BBA0DBD8-DCE
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "N16_HT1", "N16_HT1", "{F6504F23-BC5C-4B63-B6EA-CC1DBA6F69E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "N16_HT1", "N16_HT1\N16_HT1.csproj", "{9B931C9D-B852-4F53-AC21-04E91C01D692}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "N16_HT1", "N16_HT1\N16_HT1.csproj", "{9B931C9D-B852-4F53-AC21-04E91C01D692}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "N16_HT2", "N16_HT2", "{08F4F27E-AC06-4149-BDF3-6E6469C72904}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "N16_HT2", "N16_HT2\N16_HT2.csproj", "{8213FB9A-5F09-4589-B8F9-58DCF6C7AEE5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "N16_HT2", "N16_HT2\N16_HT2.csproj", "{8213FB9A-5F09-4589-B8F9-58DCF6C7AEE5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "N17_HT1", "N17_HT1\N17_HT1.csproj", "{B8F2FDF4-5E8A-4E33-97F5-33A7EF7E765C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "N17", "N17", "{9B79AF1D-7835-40D1-9478-26BD79673DEA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "N17_HT2", "N17_HT2\N17_HT2.csproj", "{65E92671-E1EA-4796-8A1B-2D6A16C4CBDF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -263,6 +269,14 @@ Global
{8213FB9A-5F09-4589-B8F9-58DCF6C7AEE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8213FB9A-5F09-4589-B8F9-58DCF6C7AEE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8213FB9A-5F09-4589-B8F9-58DCF6C7AEE5}.Release|Any CPU.Build.0 = Release|Any CPU
{B8F2FDF4-5E8A-4E33-97F5-33A7EF7E765C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8F2FDF4-5E8A-4E33-97F5-33A7EF7E765C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8F2FDF4-5E8A-4E33-97F5-33A7EF7E765C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8F2FDF4-5E8A-4E33-97F5-33A7EF7E765C}.Release|Any CPU.Build.0 = Release|Any CPU
{65E92671-E1EA-4796-8A1B-2D6A16C4CBDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{65E92671-E1EA-4796-8A1B-2D6A16C4CBDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{65E92671-E1EA-4796-8A1B-2D6A16C4CBDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{65E92671-E1EA-4796-8A1B-2D6A16C4CBDF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -319,6 +333,8 @@ Global
{9B931C9D-B852-4F53-AC21-04E91C01D692} = {F6504F23-BC5C-4B63-B6EA-CC1DBA6F69E4}
{08F4F27E-AC06-4149-BDF3-6E6469C72904} = {BBA0DBD8-DCE0-454B-A9ED-757F4ED6CF86}
{8213FB9A-5F09-4589-B8F9-58DCF6C7AEE5} = {08F4F27E-AC06-4149-BDF3-6E6469C72904}
{B8F2FDF4-5E8A-4E33-97F5-33A7EF7E765C} = {9B79AF1D-7835-40D1-9478-26BD79673DEA}
{65E92671-E1EA-4796-8A1B-2D6A16C4CBDF} = {9B79AF1D-7835-40D1-9478-26BD79673DEA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8B77269B-B20D-4860-9637-2E2771096EE6}
Expand Down
12 changes: 12 additions & 0 deletions N17_HT1/AUDI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace N17_HT1
{
internal class Class1
{
}
}
12 changes: 12 additions & 0 deletions N17_HT1/BMW.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace N17_HT1
{
public class BMW
{
}
}
51 changes: 51 additions & 0 deletions N17_HT1/CarRental.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace N17_HT1
{
public abstract class CarRental
{
protected CarRental(string BrandName)
{
this.BrandName = BrandName;
}
public bool IsRented { get; set; } = false;
public DateTime RentStartTime { get; set; }
public double Balance { get; set; }
public string BrandName { get; set; }
public Guid Id { get; set; }

public override string ToString()
{
return $"BrendName: {BrandName}\tRentStartTime - {RentStartTime}";
}
}
public sealed class BMW : CarRental
{
public static string ModelName { get; set; }
public static double RentPriceHour { get; set; }
public BMW(string modelName):
base("BMW")
{
ModelName = modelName;
RentPriceHour = 30;
}
}

public sealed class AUDI : CarRental
{
public static string ModelName { get; set; }
public static double RentPriceHour { get; set; }
public AUDI(string modelName) :
base("AUDI")
{
ModelName = modelName;
RentPriceHour = 30;
}
}



}
69 changes: 69 additions & 0 deletions N17_HT1/CarRentalManagement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace N17_HT1
{
public class CarRentalManagement
{
private List<CarRental> Cars { get;set; }

public CarRentalManagement()
{

Cars = new List<CarRental>();
}

public void Add(CarRental car)
{
Cars.Add(car);
}

public CarRental? Rent(string brendname)
{
foreach (var car in Cars)
{
if (car.BrandName.Contains(brendname) && car.IsRented == false){
car.RentStartTime = DateTime.Now;
car.IsRented = true;
return car;
}
}
return null;
}

public CarRental? Return(CarRental car)
{
foreach(var Car in Cars)
{
if(Car.Id == car.Id)
{
Car.IsRented = false;
if(car.BrandName == "BMW")
{

Car.Balance = (DateTime.Now - car.RentStartTime).TotalSeconds * BMW.RentPriceHour;
}
else if(car.BrandName == "AUDI")
{
Car.Balance = (DateTime.Now - car.RentStartTime).TotalSeconds * AUDI.RentPriceHour;

}
}
}
return null;
}
public void CalculateBalance()
{
double calculatebalance = 0;
foreach (CarRental car in Cars)
{
calculatebalance += car.Balance;
}
Console.WriteLine(calculatebalance);
}

}
}
10 changes: 10 additions & 0 deletions N17_HT1/N17_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>
20 changes: 20 additions & 0 deletions N17_HT1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using N17_HT1;
var Menegment = new CarRentalManagement();
CarRental bmw1 = new BMW("X1");
CarRental bmw2 = new BMW("X2");
CarRental bmw3 = new BMW("X3");
CarRental audi1 = new BMW("Y1");
CarRental audi2 = new BMW("Y1");
CarRental audi3 = new BMW("Y3");
Menegment.Add(bmw1);
Menegment.Add(bmw2);
Menegment.Add(bmw3);
Menegment.Add(audi1);
Menegment.Add(audi2);
Menegment.Add(audi3);


Console.WriteLine( Menegment.Rent("BMW"));
await Task.Delay(1000 * 3);
Console.WriteLine(Menegment.Return(bmw1));
Menegment.CalculateBalance();
12 changes: 12 additions & 0 deletions N17_HT2/Chat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace N17_HT2
{
internal class Chat
{
}
}
12 changes: 12 additions & 0 deletions N17_HT2/ChatMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace N17_HT2
{
internal class ChatMessage
{
}
}
12 changes: 12 additions & 0 deletions N17_HT2/MessgeValidator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace N17_HT2
{
internal class MessgeValidator
{
}
}
10 changes: 10 additions & 0 deletions N17_HT2/N17_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>
1 change: 1 addition & 0 deletions N17_HT2/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Console.WriteLine("jn");

0 comments on commit f7a9d63

Please sign in to comment.