fork download
  1. using System;
  2. using static System.Console;
  3. using System.Collections.Generic;
  4.  
  5. public class MainClass {
  6. public static Random Random = new Random();
  7.  
  8. public static List<string> Marcas= new List<string>() { "Toyota", "BMW", "Volkswagen", "GM", "Mercedes" };
  9. public static List<string> Modelos = new List<string>() { "1.0", "1.4", "1.6", "1.8", "2.0" };
  10. public static List<string> Cores = new List<string>() { "Branco", "Prata", "Preto", "Cinza", "Vermelho" };
  11.  
  12. public static void Main(string[] args) {
  13. for (int i = 1; i <= 5; i++) {
  14. var carro = gerarCarro();
  15. WriteLine(carro.Marca);
  16. WriteLine(carro.Modelo);
  17. WriteLine(carro.Cor);
  18. WriteLine(carro.Ano);
  19. WriteLine();
  20. }
  21. }
  22. public static Carro gerarCarro() {
  23. return new Carro() {
  24. Marca = Marcas[Random.Next(0, 5)],
  25. Modelo = Modelos[Random.Next(0, 5)],
  26. Cor = Cores[Random.Next(0, 5)],
  27. Ano = Random.Next(2000, 2018) };
  28. }
  29. public class Carro {
  30. public string Marca { get; set; }
  31. public string Modelo { get; set; }
  32. public string Cor { get; set; }
  33. public int Ano { get; set; }
  34. }
  35. }
  36.  
  37. //https://pt.stackoverflow.com/q/226458/101
Success #stdin #stdout 0.02s 16152KB
stdin
Standard input is empty
stdout
Volkswagen
1.6
Preto
2000

Volkswagen
2.0
Vermelho
2011

Volkswagen
2.0
Vermelho
2010

Mercedes
1.6
Preto
2013

Mercedes
2.0
Vermelho
2010