fork download
  1. using static System.Console;
  2.  
  3. public class Program {
  4. public static void Main() => new Cliente().Add();
  5. }
  6.  
  7. public class Pessoa {
  8. public string Nome { get; set; }
  9. public int Idade { get; set; }
  10. public virtual void Add() {
  11. Nome = ReadLine();
  12. Idade = int.Parse(ReadLine()); //não é assim que faz, só pra simplificar
  13. }
  14. }
  15.  
  16. public class Cliente : Pessoa {
  17. public int Codigo { get; set; }
  18. public override void Add() {
  19. base.Add();
  20. Codigo = int.Parse(ReadLine());
  21. var moto = new Moto();
  22. moto.AddMoto();
  23. moto.ExibirDados();
  24. ExibirDados();
  25. }
  26. public void ExibirDados() => WriteLine("Titular: " + Nome);
  27. }
  28.  
  29. public class Moto {
  30. public string Cor { get; set; }
  31. public void AddMoto() => Cor = ReadLine();
  32. public void ExibirDados() => WriteLine("Cor: " + Cor);
  33. }
  34.  
  35. //https://pt.stackoverflow.com/q/109591/101
Runtime error #stdin #stdout #stderr 0.02s 16204KB
stdin
a
1
stdout
Standard output is empty
stderr
Unhandled Exception:
System.ArgumentNullException: Value cannot be null.
Parameter name: s
  at System.Int32.Parse (System.String s) [0x00003] in <6649516e5b3542319fb262b421af0adb>:0 
  at Cliente.Add () [0x0000c] in <1c362a71be2742619fd36593d10889b7>:0 
  at Program.Main () [0x00005] in <1c362a71be2742619fd36593d10889b7>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentNullException: Value cannot be null.
Parameter name: s
  at System.Int32.Parse (System.String s) [0x00003] in <6649516e5b3542319fb262b421af0adb>:0 
  at Cliente.Add () [0x0000c] in <1c362a71be2742619fd36593d10889b7>:0 
  at Program.Main () [0x00005] in <1c362a71be2742619fd36593d10889b7>:0