Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace TareaConsolaCasa01.Clases
- {
- public class cProducto
- {
- int id;
- string nombre;
- int precio;
- public cProducto()
- {
- }
- public int ID{
- set { id = value; }
- get { return id; }
- }
- public string Nombre
- {
- set { nombre = value; }
- get { return nombre; }
- }
- public int Precio
- {
- set { precio = value; }
- get { return precio; }
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace TareaConsolaCasa01.Clases
- {
- class cServicio
- {
- int id;
- string nombre;
- int precio;
- public cServicio()
- {
- }
- public int ID{
- set { id = value; }
- get { return id; }
- }
- public string Nombre
- {
- set { nombre = value; }
- get { return nombre; }
- }
- public int Precio
- {
- set { precio = value; }
- get { return precio; }
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using TareaConsolaCasa01.Clases;
- namespace TareaConsolaCasa01.Funcionalidades
- {
- class fProductosServicios
- {
- public void AgregarProducto(cProducto[] x)
- {
- for (int i = 0; i < x.Length; i++)
- {
- x [i] = new cProducto();
- Console.Write("\ningrese id :");
- x[i].ID = int.Parse(Console.ReadLine());
- Console.Write("\ningrese nombre :");
- x[i].Nombre = Console.ReadLine();
- Console.Write("\ningrese precio :");
- x[i].Precio = int.Parse(Console.ReadLine());
- Console.Write("Pulse una tecla para continuar..");
- Console.ReadKey();
- Console.Clear();
- }
- }
- public void AgregarServicio(cServicio[] y)
- {
- for (int i = 0; i < y.Length; i++)
- {
- y[i] = new cServicio();
- Console.Write("\ningrese id :");
- y[i].ID = int.Parse(Console.ReadLine());
- Console.Write("\ningrese nombre :");
- y[i].Nombre = Console.ReadLine();
- Console.Write("\ningrese precio :");
- y[i].Precio = int.Parse(Console.ReadLine());
- Console.Write("Pulse una tecla para continuar..");
- Console.ReadKey();
- Console.Clear();
- }
- }
- public void Mostrar(cProducto[]x, cServicio[]y)
- {
- for (int i = 0; i < x.Length; i++)
- {
- Console.Write("\n**********Datos Producto**********\n");
- Console.Write("\nproducto NĀ° :" +x[i]);
- Console.Write("\nID Producto :"+x[i].ID);
- Console.Write("\nNombre Producto :"+x[i].Nombre);
- Console.Write("\nPrecio Producto :"+x[i].Precio);
- Console.Write("\n\n**********Datos Producto**********\n");
- }
- for (int i = 0; i < y.Length; i++)
- {
- Console.Write("\n**********Datos Servicio**********\n");
- Console.Write("\nID Servicio :"+y[i].ID);
- Console.Write("\nNombre Servicio :"+y[i].Nombre);
- Console.Write("\nPrecio Servicio :"+y[i].Precio);
- Console.Write("\n\n**********Datos Servicio**********\n");
- }
- Console.Write("\nproductos ingresados :" + x.Length);
- Console.Write("\nservicios ingresados :" + y.Length);
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using TareaConsolaCasa01.Clases;
- using TareaConsolaCasa01.Funcionalidades;
- namespace TareaConsolaCasa01
- {
- class Program
- {
- static void Main(string[] args)
- {
- fProductosServicios a = new fProductosServicios();
- cProducto[] producto = new cProducto[0];
- cServicio[] servicios = new cServicio[0];
- int opciones;
- string salir = null;
- do{
- Console.Write("**********Inicio**********");
- Console.Write(
- "\n1-Ingresar Productos " +
- "\n2-Ingresar Servicios " +
- "\n3-Mostrar "+
- "\n4-Salir\n\n");
- Console.Write("\nseleccione una opcion ");
- try {
- opciones = int.Parse(Console.ReadLine());
- Console.Clear();
- switch(opciones){
- case 1:
- Console.Write("\ningrese cantidad de productos :");
- int cantidadProductos = 0;
- try
- {
- cantidadProductos = int.Parse(Console.ReadLine());
- if (cantidadProductos <= 0)
- {
- Console.Write("error");
- Console.Clear();
- }
- }
- catch (Exception ex)
- {
- Console.Write(ex.Message);
- }
- producto = new cProducto[cantidadProductos];
- a.AgregarProducto(producto);
- break;
- case 2:
- Console.Write("\ningrese cantidad de servicios :");
- int cantidadServicios = 0;
- try
- {
- cantidadServicios = int.Parse(Console.ReadLine());
- if (cantidadServicios <= 0)
- {
- Console.Write("error");
- Console.Clear();
- }
- }
- catch (Exception ex)
- {
- Console.Write(ex.Message);
- }
- servicios = new cServicio[cantidadServicios];
- a.AgregarServicio(servicios);
- break;
- case 3:
- a.Mostrar(producto, servicios);
- Console.Write("\npulse una tecla para continuar...");
- Console.ReadKey();
- Console.Clear();
- break;
- case 4:
- Console.Write("desea salir? s/n\n");
- salir = Console.ReadLine();
- Console.Clear();
- break;
- default:
- Console.Write("opcion no valida");
- Console.Write("\npulse una tecla para continuar...");
- Console.ReadKey();
- Console.Clear();
- break;
- }
- }
- catch (Exception ex)
- {
- Console.Write(ex.Message);
- Console.Write("\npulse una tecla para continuar...");
- Console.ReadKey();
- Console.Clear();
- }
- } while (salir != "s");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement