Advertisement
NameL3ss

DemoappProductosServicios

Aug 28th, 2014
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.71 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 TareaConsolaCasa01.Clases
  8. {
  9. public class cProducto
  10. {
  11. int id;
  12. string nombre;
  13. int precio;
  14.  
  15. public cProducto()
  16. {
  17.  
  18. }
  19.  
  20. public int ID{
  21. set { id = value; }
  22. get { return id; }
  23.  
  24. }
  25.  
  26. public string Nombre
  27. {
  28. set { nombre = value; }
  29. get { return nombre; }
  30. }
  31.  
  32. public int Precio
  33. {
  34. set { precio = value; }
  35. get { return precio; }
  36. }
  37. }
  38. }
  39.  
  40.  
  41. using System;
  42. using System.Collections.Generic;
  43. using System.Linq;
  44. using System.Text;
  45. using System.Threading.Tasks;
  46.  
  47. namespace TareaConsolaCasa01.Clases
  48. {
  49. class cServicio
  50. {
  51. int id;
  52. string nombre;
  53. int precio;
  54.  
  55. public cServicio()
  56. {
  57.  
  58. }
  59.  
  60. public int ID{
  61. set { id = value; }
  62. get { return id; }
  63.  
  64. }
  65.  
  66. public string Nombre
  67. {
  68. set { nombre = value; }
  69. get { return nombre; }
  70. }
  71.  
  72. public int Precio
  73. {
  74. set { precio = value; }
  75. get { return precio; }
  76. }
  77. }
  78. }
  79.  
  80. using System;
  81. using System.Collections.Generic;
  82. using System.Linq;
  83. using System.Text;
  84. using System.Threading.Tasks;
  85. using TareaConsolaCasa01.Clases;
  86.  
  87.  
  88. namespace TareaConsolaCasa01.Funcionalidades
  89. {
  90. class fProductosServicios
  91. {
  92.  
  93. public void AgregarProducto(cProducto[] x)
  94. {
  95.  
  96. for (int i = 0; i < x.Length; i++)
  97. {
  98.  
  99. x [i] = new cProducto();
  100. Console.Write("\ningrese id :");
  101. x[i].ID = int.Parse(Console.ReadLine());
  102. Console.Write("\ningrese nombre :");
  103. x[i].Nombre = Console.ReadLine();
  104. Console.Write("\ningrese precio :");
  105. x[i].Precio = int.Parse(Console.ReadLine());
  106.  
  107. Console.Write("Pulse una tecla para continuar..");
  108. Console.ReadKey();
  109.  
  110. Console.Clear();
  111. }
  112.  
  113. }
  114.  
  115. public void AgregarServicio(cServicio[] y)
  116. {
  117. for (int i = 0; i < y.Length; i++)
  118. {
  119.  
  120. y[i] = new cServicio();
  121. Console.Write("\ningrese id :");
  122. y[i].ID = int.Parse(Console.ReadLine());
  123. Console.Write("\ningrese nombre :");
  124. y[i].Nombre = Console.ReadLine();
  125. Console.Write("\ningrese precio :");
  126. y[i].Precio = int.Parse(Console.ReadLine());
  127.  
  128. Console.Write("Pulse una tecla para continuar..");
  129. Console.ReadKey();
  130.  
  131.  
  132. Console.Clear();
  133. }
  134. }
  135.  
  136. public void Mostrar(cProducto[]x, cServicio[]y)
  137. {
  138. for (int i = 0; i < x.Length; i++)
  139. {
  140.  
  141. Console.Write("\n**********Datos Producto**********\n");
  142. Console.Write("\nproducto NĀ° :" +x[i]);
  143. Console.Write("\nID Producto :"+x[i].ID);
  144. Console.Write("\nNombre Producto :"+x[i].Nombre);
  145. Console.Write("\nPrecio Producto :"+x[i].Precio);
  146. Console.Write("\n\n**********Datos Producto**********\n");
  147.  
  148.  
  149. }
  150.  
  151.  
  152.  
  153. for (int i = 0; i < y.Length; i++)
  154. {
  155. Console.Write("\n**********Datos Servicio**********\n");
  156. Console.Write("\nID Servicio :"+y[i].ID);
  157. Console.Write("\nNombre Servicio :"+y[i].Nombre);
  158. Console.Write("\nPrecio Servicio :"+y[i].Precio);
  159. Console.Write("\n\n**********Datos Servicio**********\n");
  160.  
  161. }
  162.  
  163. Console.Write("\nproductos ingresados :" + x.Length);
  164.  
  165. Console.Write("\nservicios ingresados :" + y.Length);
  166.  
  167. }
  168. }
  169. }
  170.  
  171.  
  172. using System;
  173. using System.Collections.Generic;
  174. using System.Linq;
  175. using System.Text;
  176. using System.Threading.Tasks;
  177. using TareaConsolaCasa01.Clases;
  178. using TareaConsolaCasa01.Funcionalidades;
  179.  
  180.  
  181. namespace TareaConsolaCasa01
  182. {
  183. class Program
  184. {
  185. static void Main(string[] args)
  186. {
  187.  
  188.  
  189. fProductosServicios a = new fProductosServicios();
  190.  
  191. cProducto[] producto = new cProducto[0];
  192. cServicio[] servicios = new cServicio[0];
  193.  
  194.  
  195.  
  196.  
  197. int opciones;
  198.  
  199. string salir = null;
  200.  
  201. do{
  202. Console.Write("**********Inicio**********");
  203.  
  204. Console.Write(
  205. "\n1-Ingresar Productos " +
  206. "\n2-Ingresar Servicios " +
  207. "\n3-Mostrar "+
  208. "\n4-Salir\n\n");
  209.  
  210. Console.Write("\nseleccione una opcion ");
  211.  
  212.  
  213. try {
  214.  
  215. opciones = int.Parse(Console.ReadLine());
  216. Console.Clear();
  217. switch(opciones){
  218.  
  219.  
  220. case 1:
  221.  
  222. Console.Write("\ningrese cantidad de productos :");
  223. int cantidadProductos = 0;
  224. try
  225. {
  226. cantidadProductos = int.Parse(Console.ReadLine());
  227. if (cantidadProductos <= 0)
  228. {
  229. Console.Write("error");
  230. Console.Clear();
  231. }
  232. }
  233. catch (Exception ex)
  234. {
  235. Console.Write(ex.Message);
  236. }
  237.  
  238. producto = new cProducto[cantidadProductos];
  239. a.AgregarProducto(producto);
  240.  
  241. break;
  242.  
  243.  
  244.  
  245. case 2:
  246.  
  247. Console.Write("\ningrese cantidad de servicios :");
  248. int cantidadServicios = 0;
  249.  
  250. try
  251. {
  252. cantidadServicios = int.Parse(Console.ReadLine());
  253. if (cantidadServicios <= 0)
  254. {
  255. Console.Write("error");
  256. Console.Clear();
  257. }
  258.  
  259.  
  260. }
  261.  
  262. catch (Exception ex)
  263. {
  264. Console.Write(ex.Message);
  265. }
  266.  
  267.  
  268. servicios = new cServicio[cantidadServicios];
  269.  
  270. a.AgregarServicio(servicios);
  271.  
  272. break;
  273.  
  274. case 3:
  275.  
  276. a.Mostrar(producto, servicios);
  277. Console.Write("\npulse una tecla para continuar...");
  278. Console.ReadKey();
  279. Console.Clear();
  280. break;
  281.  
  282.  
  283. case 4:
  284.  
  285.  
  286. Console.Write("desea salir? s/n\n");
  287. salir = Console.ReadLine();
  288. Console.Clear();
  289. break;
  290.  
  291.  
  292. default:
  293.  
  294.  
  295. Console.Write("opcion no valida");
  296. Console.Write("\npulse una tecla para continuar...");
  297. Console.ReadKey();
  298. Console.Clear();
  299.  
  300. break;
  301.  
  302. }
  303.  
  304. }
  305.  
  306. catch (Exception ex)
  307. {
  308. Console.Write(ex.Message);
  309. Console.Write("\npulse una tecla para continuar...");
  310. Console.ReadKey();
  311. Console.Clear();
  312. }
  313.  
  314.  
  315. } while (salir != "s");
  316. }
  317. }
  318. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement