// POO con menos if's (c) 2024 Baltasar <baltasarq@gmail.com> MIT License
using System;
using System.Text ;
using System.Collections .Generic ;
class POI {
public /*required*/ string Name { get; init; }
public /*required*/ double Lat { get; init; }
public /*required*/ double Lon { get; init; }
public override string ToString( )
{
return $"{this.Name}: W{this.Lon}º N{this.Lat}º" ;
}
}
class City: POI {
public override string ToString( )
{
return "Ciudad de " + base.ToString ( ) ;
}
}
class Monument: POI {
public override string ToString( )
{
return "Monumento de " + base.ToString ( ) ;
}
}
class Mountain: POI {
public override string ToString( )
{
return "Cima del " + base.ToString ( ) ;
}
}
class Lake: POI {
public override string ToString( )
{
return "Lago " + base.ToString ( ) ;
}
}
class Reporter {
public Reporter( IEnumerable< POI> lpois)
{
this.lpois = new List< POI> ( lpois ) ;
}
public IList< POI> LPOIS => new List< POI> ( this.lpois ) ;
public string Report( )
{
var toret = new StringBuilder( ) ;
foreach( var poi in this.lpois ) {
toret.AppendLine ( poi.ToString ( ) ) ;
}
return toret.ToString ( ) ;
}
private List< POI> lpois;
}
public class Test
{
public static void Main( )
{
var l1 = new List< POI> {
new City { Name = "El Cabo" ,
Lat = - 34.0558188 ,
Lon = 18.3003856 } ,
new Mountain { Name = "Everest" ,
Lat = 27.9881186 ,
Lon = 86.9043755 } ,
new Monument { Name = "Torre Eiffel" ,
Lat = 48.8583 ,
Lon = - 2.2945 } ,
new Lake { Name = "Español" ,
Lat = 43.6150755 ,
Lon = 173.1834932 } ,
} ;
Console.WriteLine ( new Reporter( l1 ) .Report ( ) ) ;
}
}
Ly8gUE9PIGNvbiBtZW5vcyBpZidzIChjKSAyMDI0IEJhbHRhc2FyIDxiYWx0YXNhcnFAZ21haWwuY29tPiBNSVQgTGljZW5zZQoKdXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uVGV4dDsKdXNpbmcgU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWM7CgoKY2xhc3MgUE9JIHsKICAgIHB1YmxpYyAvKnJlcXVpcmVkKi8gc3Ry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q8UE9JPiBMUE9JUyA9PiBuZXcgTGlzdDxQT0k+KCB0aGlzLmxwb2lzICk7CgogICAgcHVibGljIHN0cmluZyBSZXBvcnQoKQogICAgewogICAgICAgIHZhciB0b3JldCA9IG5ldyBTdHJpbmdCdWlsZGVyKCk7CgogICAgICAgIGZvcmVhY2godmFyIHBvaSBpbiB0aGlzLmxwb2lzKSB7CiAgICAgICAgICAgIHRvcmV0LkFwcGVuZExpbmUoIHBvaS5Ub1N0cmluZygpICk7CiAgICAgICAgfQoKICAgICAgICByZXR1cm4gdG9yZXQuVG9TdHJpbmcoKTsKICAgIH0KICAgIAogICAgcHJpdmF0ZSBMaXN0PFBPST4gbHBvaXM7Cn0KCnB1YmxpYyBjbGFzcyBUZXN0CnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBNYWluKCkKCXsKCQl2YXIgbDEgPSBuZXcgTGlzdDxQT0k+IHsKCQkgICAgbmV3IENpdHkgeyBOYW1lID0gIkVsIENhYm8iLAoJCSAgICAgICAgICAgICBMYXQgPSAtMzQuMDU1ODE4OCwKCQkgICAgICAgICAgICAgTG9uID0gMTguMzAwMzg1NiB9LAoJCSAgICBuZXcgTW91bnRhaW4geyBOYW1lID0gIkV2ZXJlc3QiLAoJCSAgICAgICAgICAgICBMYXQgPSAyNy45ODgxMTg2LAogICAgICAgICAgICAgICAgICAgICBMb24gPSA4Ni45MDQzNzU1IH0sCiAgICAgICAgICAgIG5ldyBNb251bWVudCB7IE5hbWUgPSAiVG9ycmUgRWlmZmVsIiwKCQkgICAgICAgICAgICAgTGF0ID0gNDguODU4MywKICAgICAgICAgICAgICAgICAgICAgTG9uID0gLTIuMjk0NSB9LAogICAgICAgICAgICBuZXcgTGFrZSB7IE5hbWUgPSAiRXNwYcOxb2wiLAogICAgICAgICAgICAgICAgICAgICBMYXQgPSA0My42MTUwNzU1LAogICAgICAgICAgICAgICAgICAgICBMb24gPSAxNzMuMTgzNDkzMiB9LAoJCX07CgoJCUNvbnNvbGUuV3JpdGVMaW5lKCBuZXcgUmVwb3J0ZXIoIGwxICkuUmVwb3J0KCkgKTsKCX0KfQo=