using System.Collections.Generic;
using System.Threading.Tasks;
public static void Main(string[] args)
Product product = new Product(301, "Cep Telefonu", 1300, 250);
Service service = new Service(601, "Halı Yıkama", 2500, 48);
Item iteml = new Product(302, "Bilgisayar", 2000, 1550);
Item item2 = new Service(601, "Araba Yıkama", 1400, 2);
Inventory inventory = new Inventory(901, "Beykent");
inventory.ItemList = new List<Item>();
inventory.ItemList.Add(product);
inventory.ItemList.Add(service);
inventory.ItemList.Add(iteml);
inventory.ItemList.Add(item2);
Console.WriteLine("Kalemler:");
foreach (Item item in inventory.ItemList)
Console.WriteLine("\t" + item.ItemName + " " + item.SalesPrice);
double averagePrice = inventory.GetAveragePrice();
Console.WriteLine("Ortalama Fiyat: " + averagePrice);
double averagePriceMin = inventory.GetAveragePrice(2000);
Console.WriteLine("Ortalama Fiyat (Min 2000): " + averagePriceMin);
Console.WriteLine("Kalemler (Min 2000):");
List<Item> resultList = inventory.GetItemsPriceMin(2000);
foreach (Item item in resultList)
Console.WriteLine("\t" + item.ItemName + " " + item.SalesPrice);
private double salesPrice;
public Item(string itemName, double salesPrice)
this.ItemName = itemName;
this.SalesPrice = salesPrice;
public string ItemName { get => itemName; set => itemName = value;}
public double SalesPrice { get => salesPrice; set => salesPrice = value;}
public class Product : Item
private double totalWeight;
public Product(long productId, string itemName, double salesPrice, double totalWeight)
: base (itemName, salesPrice)
this.Productld = productId;
this.TotalWeight = totalWeight;
public long Productld { get => productId; set => productId = value; }
public double TotalWeight { get => totalWeight; set => totalWeight = value; }
public class Service : Item
private double totalTime;
public Service(long serviceId, string itemName, double salesPrice, double totalTime )
: base (itemName, salesPrice)
this.Serviceld = serviceId;
this.TotalTime = totalTime;
public long Serviceld { get => serviceId; set => serviceId = value; }
public double TotalTime { get => totalTime; set => totalTime = value; }
private long inventoryId;
private string inventoryName;
private List<Item> itemList;
public Inventory(long inventoryId, string inventoryName)
this.Inventoryld = inventoryId;
this.InventoryName = inventoryName;
public double GetAveragePrice(double minimumPrice)
foreach (Item item in itemList)
if (item.SalesPrice >= minimumPrice)
totalPrice += item.SalesPrice;
double averagePrice = totalPrice / itemList.Count;
public double GetAveragePrice()
return GetAveragePrice(0);
public List<Item> GetItemsPriceMin(double minimumPrice)
List<Item> resultList = new List<Item>();
foreach (Item item in itemList)
if (item.SalesPrice >= minimumPrice)
public long Inventoryld { get => inventoryId; set => inventoryId = value; }
public string InventoryName { get => inventoryName; set => inventoryName = value; }
public List<Item> ItemList { get => itemList; set => itemList = value; }