Guest User

Untitled

a guest
Nov 23rd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace TextosApp
  9. {
  10. class Program
  11. {
  12. static void Main(string[] args)
  13. {
  14. //Inicializa un Anotador
  15. Anotador anotador = new Anotador();
  16.  
  17. //La interfaz inicia y pregunta que hacer
  18. Console.WriteLine("Qué desea hacer? Tipee 'ayuda' para más información.");
  19. Console.WriteLine("Inserte un comando: ");
  20. Console.WriteLine("");
  21.  
  22. bool salir = true;
  23.  
  24. //Loop del programa
  25. while (salir)
  26. {
  27. string input = Console.ReadLine();
  28.  
  29. if (input == "agregar")
  30. {
  31. anotador.AgregarTexto();
  32. Console.WriteLine("");
  33. Console.WriteLine("Texto agregado con éxito.");
  34. Console.WriteLine("");
  35. Console.WriteLine("Inserte un comando:");
  36. Console.WriteLine("");
  37. }
  38. else if (input == "listar")
  39. {
  40. Console.WriteLine("");
  41. anotador.ListarTextos();
  42. Console.WriteLine("");
  43. Console.WriteLine("Inserte un comando: ");
  44. Console.WriteLine("");
  45. }
  46. else if (input == "ayuda")
  47. {
  48. Console.WriteLine("");
  49. Console.WriteLine("Los comandos disponibles son: agregar - listar - ayuda - salir");
  50. Console.WriteLine("");
  51. }
  52. else if (input == "editar")
  53. {
  54. Console.WriteLine("");
  55. Console.WriteLine("Inserte el Id/Numero de texto a editar");
  56. Console.WriteLine("");
  57. int id = Int32.Parse(Console.ReadLine());
  58. anotador.EditarTexto(id);
  59. }
  60. else if (input == "salir")
  61. {
  62. salir = false;
  63. }
  64. else
  65. {
  66. Console.WriteLine("");
  67. Console.WriteLine("Inserte un comando válido: ");
  68. Console.WriteLine("");
  69. }
  70. }
  71. }
  72. }
  73. }
  74.  
  75. using System;
  76. using System.Collections.Generic;
  77. using System.Linq;
  78. using System.Text;
  79. using System.Threading.Tasks;
  80.  
  81. namespace TextosApp
  82. {
  83. class Anotador
  84. {
  85.  
  86. public Anotador()
  87. {
  88. textos = new List<object>();
  89. }
  90.  
  91. public void AgregarTexto()
  92. {
  93. Console.WriteLine("");
  94. Console.WriteLine("Inserte un nombre para su texto:");
  95. Console.WriteLine("");
  96. textos.Add(new Texto()
  97. {
  98. Id = textos.Count,
  99. Leido = false,
  100. Nombre = Console.ReadLine()
  101. });
  102. }
  103.  
  104. public void ListarTextos()
  105. {
  106. if (textos.Count > 0)
  107. {
  108. foreach (Texto texto in textos)
  109. {
  110. Console.WriteLine("");
  111. Console.WriteLine("Número: " + texto.Id);
  112. Console.WriteLine("Nombre del texto: " + texto.Nombre);
  113. Console.WriteLine(texto.Leido ? "(Has leido este texto.)" : "(No has leido este texto.)");
  114. Console.WriteLine("");
  115. }
  116. }
  117. else
  118. {
  119. Console.WriteLine("No hay textos!");
  120. }
  121.  
  122. }
  123.  
  124. public void EditarTexto(int id)
  125. {
  126. Console.WriteLine("");
  127. Console.WriteLine("Introduzca el nuevo texto: ");
  128. Console.WriteLine("");
  129. string nuevoTexto = Console.ReadLine();
  130. textos[id].Nombre = nuevoTexto;
  131. }
  132.  
  133. public List<object> textos;
  134.  
  135. }
  136. }
  137.  
  138. using System;
  139. using System.Collections.Generic;
  140. using System.Linq;
  141. using System.Text;
  142. using System.Threading.Tasks;
  143.  
  144. namespace TextosApp
  145. {
  146. class Texto //Clase simple
  147. {
  148. public int Id { get; set; }
  149. public string Nombre { get; set; }
  150. public bool Leido { get; set; }
  151. }
  152. }
Add Comment
Please, Sign In to add comment