In order not to have to manually write the data after an update on the objects, I decided to create a method of type static
to be accessed by passing the object as a parameter.
public static void Relatorio(Trem trem)
{
Console.WriteLine($"{trem} - PESO ATUAL: {trem.getPesoVagao()}");
Console.WriteLine($"{trem} - PESO SUPORTADO: {trem.getCargaMAX()}");
Console.WriteLine($"{trem} - CARGA DISPONÍVEL: {trem.CargaRestante()}");
Console.WriteLine();
Console.WriteLine();
}
ThiswouldpreventmefromwritingthereportinMain()
wheneverImadeachangetotheobject,butthereturnednamethatshouldbe"T2" is returning as SobrecargaDeMetodos.Trem
.
I call the method as follows passing the object to be parsed as parameter. The part of showing the result works perfectly, but the name does not.
Trem.Relatorio(T2);