From 881be802ba6c8cb0ae86b6bf18f23f41c93a90d0 Mon Sep 17 00:00:00 2001 From: kuncsanadlajos Date: Thu, 11 Apr 2024 13:56:08 +0200 Subject: [PATCH] keszul --- RealEstate/Ad.cs | 16 ++++++++++++++++ RealEstate/Program.cs | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/RealEstate/Ad.cs b/RealEstate/Ad.cs index 69ba810..31ba35b 100644 --- a/RealEstate/Ad.cs +++ b/RealEstate/Ad.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.IO; + namespace RealEstate { @@ -57,6 +59,12 @@ namespace RealEstate { List lista = new List(); + string[] sorok = File.ReadAllLines(filename); + for (int i = 1; i < sorok.Length; i++) + { + lista.Add(new Ad(sorok[i])); + } + return lista; } @@ -74,6 +82,14 @@ namespace RealEstate ImageUrl = t[7]; CreateAt = DateTime.Parse(t[8]); + Seller = new Seller(int.Parse(t[9]), t[10], t[11]); + Category = new Category(int.Parse(t[12]), t[13]); + } + public double DistanceTo(double lat2, double long2) + { + double lat1 = double.Parse(LatLong.Split(',')[0].Replace('.',',')); + double long1 = double.Parse(LatLong.Split(',')[1].Replace('.',',')); + return Math.Sqrt(); } } } diff --git a/RealEstate/Program.cs b/RealEstate/Program.cs index e15d9e6..1815c2e 100644 --- a/RealEstate/Program.cs +++ b/RealEstate/Program.cs @@ -10,7 +10,25 @@ namespace RealEstate { static void Main(string[] args) { + List hirdetesek = Ad.LoadFromCsv(@"..\..\realestates.csv"); + double fszsumma = 0; + double darab = 0; + foreach (var item in hirdetesek) + { + if (item.Floors == 0) + { + fszsumma += item.Area; + darab++; + } + } + double atlag = fszsumma / darab; + Console.WriteLine($"6.feladat: A földszinti ingatlanok átlagos alapterülete: {atlag:F2} m2."); + + //6.feladat - Lambda + //double atlag2 = hirdetesek.Average(h => h.Area); + double atlag2 = hirdetesek.Where(h => h.Floors == 0).Average(h => h.Area); + Console.WriteLine($"6.feladat/2: A földszinti ingatlanok átlagos alapterülete: {atlag2:F2} m2."); } } }