-
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
c37f69e
commit f7a9d63
Showing
12 changed files
with
239 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
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 | ||
{ | ||
} | ||
} |
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,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace N17_HT1 | ||
{ | ||
public class BMW | ||
{ | ||
} | ||
} |
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,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; | ||
} | ||
} | ||
|
||
|
||
|
||
} |
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,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); | ||
} | ||
|
||
} | ||
} |
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,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(); |
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,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace N17_HT2 | ||
{ | ||
internal class Chat | ||
{ | ||
} | ||
} |
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,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace N17_HT2 | ||
{ | ||
internal class ChatMessage | ||
{ | ||
} | ||
} |
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,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace N17_HT2 | ||
{ | ||
internal class MessgeValidator | ||
{ | ||
} | ||
} |
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 @@ | ||
Console.WriteLine("jn"); |