From a0a6b91945e3b07fe72fbb26e9a473d05306a36a Mon Sep 17 00:00:00 2001 From: kuncsanadlajos Date: Thu, 18 Apr 2024 13:13:25 +0200 Subject: [PATCH] 8. --- RealEstate/Ad.cs | 3 ++- RealEstate/Program.cs | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/RealEstate/Ad.cs b/RealEstate/Ad.cs index 31ba35b..b1d9853 100644 --- a/RealEstate/Ad.cs +++ b/RealEstate/Ad.cs @@ -85,11 +85,12 @@ namespace RealEstate Seller = new Seller(int.Parse(t[9]), t[10], t[11]); Category = new Category(int.Parse(t[12]), t[13]); } + //7. feladat 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(); + return Math.Sqrt(Math.Pow(lat1-lat2,2)+ Math.Pow(long1-long2,2)); } } } diff --git a/RealEstate/Program.cs b/RealEstate/Program.cs index 1815c2e..1bcf389 100644 --- a/RealEstate/Program.cs +++ b/RealEstate/Program.cs @@ -25,10 +25,19 @@ namespace RealEstate double atlag = fszsumma / darab; Console.WriteLine($"6.feladat: A földszinti ingatlanok átlagos alapterülete: {atlag:F2} m2."); - //6.feladat - Lambda + //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."); + + //8. feladat + List tehermentesek = hirdetesek.Where(h => h.FreeOfCharge).ToList().OrderBy(h => h.DistanceTo(47.4164220114023, 19.066342425796986)).ToList(); + Ad legkozelebbi = tehermentesek[0]; + Console.WriteLine("8. feladat: A Mesevár óvodához legközelebbi tehermentes ingatlan adatai: "); + Console.WriteLine($"\tEladó neve: {legkozelebbi.Seller.Name}"); + Console.WriteLine($"\tEladó telefonja: {legkozelebbi.Seller.Phone}"); + Console.WriteLine($"\tAlapterület: {legkozelebbi.Area}"); + Console.WriteLine($"\tSzobák száma: {legkozelebbi.Rooms}"); } } }