initial commit v2

This commit is contained in:
2026-09-03 21:06:39 +01:00
commit 4228ccb030
27 changed files with 981 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
namespace OrderDomain;
public class Order
{
public List<OrderLine> Lines { get; } = new();
public decimal Total => Lines.Sum(l => l.Value);
public void AddLine(decimal unitPrice, int quantity)
=> Lines.Add(new OrderLine(unitPrice, quantity));
public void ApplyDiscount(int lineIndex)
=> Lines[lineIndex].ApplyDiscount();
}
+7
View File
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
+19
View File
@@ -0,0 +1,19 @@
namespace OrderDomain;
public class OrderLine
{
public decimal UnitPrice { get; }
public int Quantity { get; }
public bool HasDiscount { get; private set; }
public decimal Value =>
HasDiscount ? UnitPrice * Quantity * 0.8m : UnitPrice * Quantity;
public OrderLine(decimal unitPrice, int quantity)
{
UnitPrice = unitPrice;
Quantity = quantity;
}
public void ApplyDiscount() => HasDiscount = true;
}