Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace facebookgroup
  8. {
  9. class Aspirante
  10. {
  11. private int edad;
  12. private bool experienciaLaboral;
  13. private bool esIngeniero;
  14.  
  15. public Aspirante(int edad, bool experiencia, bool campoLaboral)
  16. {
  17. this.edad = edad;
  18. this.experienciaLaboral = experiencia;
  19. this.esIngeniero = campoLaboral;
  20. }
  21.  
  22. public void datosDeAspirante()
  23. {
  24. Console.WriteLine("EDAD --> "+ edad);
  25. Console.WriteLine("EXPERIENCIA L ABORAL? --> " + experienciaLaboral);
  26. Console.WriteLine("ASPIRANTE ES INGENIERO? --> " + esIngeniero);
  27. }
  28.  
  29. public int edadDeAspirante()
  30. {
  31. return edad;
  32. }
  33.  
  34. public bool experienciaDeAspirante()
  35. {
  36. return experienciaLaboral;
  37. }
  38.  
  39. public bool campoLaboralDeAspirante()
  40. {
  41. return esIngeniero;
  42. }
  43. }
  44. class ReportadorDeAspirantes
  45. {
  46. private int[] edades = {16,17,18,20,24,26};
  47. private Aspirante[] aspirantes;
  48. private Random datosAleatorios;
  49.  
  50. public ReportadorDeAspirantes(int nroDeAspirantes)
  51. {
  52. aspirantes = new Aspirante[nroDeAspirantes];
  53. datosAleatorios = new Random();
  54. crearAspirantes();
  55. }
  56.  
  57. private int edadDeAspirante()
  58. {
  59. return datosAleatorios.Next(edades[0],edades[edades.Length -1]);
  60. }
  61.  
  62. private bool campoLaboral()
  63. {
  64. if (datosAleatorios.Next(2) % 2 == 0) { return true;}
  65. return false;
  66. }
  67.  
  68. private void crearAspirantes()
  69. {
  70. for (int aspirante = 0; aspirante < aspirantes.Length; ++aspirante)
  71. aspirantes[aspirante] = new Aspirante(edadDeAspirante(), campoLaboral(), campoLaboral());
  72. }
  73.  
  74. private bool esAspiranteAceptado(int aspirante)
  75. {
  76. return aspirantes[aspirante].edadDeAspirante() > 18 &&
  77. aspirantes[aspirante].experienciaDeAspirante() == true &&
  78. aspirantes[aspirante].campoLaboralDeAspirante() == true;
  79. }
  80.  
  81. public int nroDeAspirantesAceptados()
  82. {
  83. int aspirantesAceptados = 0;
  84. for (int aspirante = 0; aspirante < aspirantes.Length; ++aspirante)
  85. if (esAspiranteAceptado(aspirante))
  86. ++aspirantesAceptados;
  87. return aspirantesAceptados;
  88. }
  89.  
  90. public void datosDeAspirantes()
  91. {
  92. Console.WriteLine("\tDATOS DE ASPIRANTES \n ==============================\n");
  93. for (int aspirante = 0; aspirante < aspirantes.Length; ++aspirante)
  94. aspirantes[aspirante].datosDeAspirante();
  95. }
  96.  
  97. public static void Main(String[] args)
  98. {
  99. Console.WriteLine("ingrese nro de aspirantes");
  100. ReportadorDeAspirantes reportadorDeAspirantes = new
  101. ReportadorDeAspirantes(Convert.ToInt32(Console.ReadLine()));
  102. Console.WriteLine("REPORTE FINALIZADO PRESION[ENTER] PARA VER RESULTADOS");
  103. Console.ReadLine();
  104. reportadorDeAspirantes.datosDeAspirantes();
  105. Console.WriteLine("\nNRO DE ASPIRANTES ACEPTADOS ---> " + reportadorDeAspirantes.nroDeAspirantesAceptados());
  106. Console.ReadLine();
  107. }
  108. }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement