Documentos de Académico
Documentos de Profesional
Documentos de Cultura
using System;
using System.Collections.Generic;
class Producto
{
public string Nombre { get; set; }
public double Precio { get; set; }
public int Stock { get; set; }
class Cliente
{
public string Nombre { get; set; }
public List<string> HistorialCompras { get; set; }
class Carrito
{
private Dictionary<Producto, int> productosEnCarrito;
public Carrito()
{
productosEnCarrito = new Dictionary<Producto, int>();
}
producto.Stock -= cantidad;
Console.WriteLine("Producto agregado al carrito: " + producto.Nombre + "
x " + cantidad);
}
else
{
Console.WriteLine("No hay suficiente stock de " + producto.Nombre +
".");
}
}
productosEnCarrito.Clear();
Console.WriteLine("Compra realizada con éxito.");
}
}
class Program
{
static void Main()
{
// Crear productos
Producto producto1 = new Producto("Pan", 11.99, 30);
Producto producto2 = new Producto("Galletas", 21.00, 40);
Producto producto3 = new Producto("Refresco", 33.50, 50);
// Crear cliente
Cliente cliente = new Cliente("Ale");
// Crear carrito
Carrito carrito = new Carrito();
if (seleccionProducto == "1")
{
carrito.AgregarAlCarrito(producto1, cantidad);
}
else if (seleccionProducto == "2")
{
carrito.AgregarAlCarrito(producto2, cantidad);
}
else if (seleccionProducto == "3")
{
carrito.AgregarAlCarrito(producto3, cantidad);
}
else
{
Console.WriteLine("Opción no válida.");
}
break;
case "2":
carrito.MostrarCarrito();
break;
case "3":
carrito.RealizarCompra(cliente);
break;
case "4":
Environment.Exit(0);
break;
default:
Console.WriteLine("Opción no válida. Inténtelo de nuevo.");
break;
}
}
}
}
INTEGRANTES DEL EQUIPO:
• ALEJANDRA VEGA ONTIVEROS
• RIVERA IZAGUIRRE GABRIELA GUADALUPE
• DIOSEL NAZARETH SAÑUDO ARMENTA
• DANYA GUADALUPE SOTO GARCIA
• GUSTAVO DELGADO PEREA