コード例 #1
0
        static void Main(string[] args)
        {
            BigSister p = new BigSister();

            cart   = new List <Product>();
            market = new List <Product>();
            receta = new List <Product>();
            receta.Add(new Product("Leche Entera", 820, 89, "1L"));
            receta.Add(new Product("Mantequilla", 850, 12, "125g"));
            receta.Add(new Product("Pimienta", 430, 84, "15g"));
            receta.Add(new Product("Sal Lobos", 330, 150, "1kg"));
            receta.Add(new Product("Láminas de Lasaña", 1250, 85, "400g"));
            receta.Add(new Product("Harina", 890, 43, "1kg"));
            receta.Add(new Product("Tomate", 1290, 200, "1kg"));
            receta.Add(new Product("Carne Molida", 4390, 15, "500g"));
            receta.Add(new Product("Aceite de Oliva", 1790, 77, "250g"));
            receta.Add(new Product("Queso Rallado Parmesano", 499, 102, "40g"));
            receta.Add(new Product("Vino Blanco Caja", 2790, 84, "2L"));
            receta.Add(new Product("Malla de Cebollas", 1090, 91, "1kg"));
            receta.Add(new Product("Bolsa de Zanahorias", 890, 74, "1un"));
            SupplyStore();



            while (true)
            {
                PrintHeader();
                Console.WriteLine("¿Que quieres hacer?\n");
                Console.WriteLine("\t1. Ver Receta");
                Console.WriteLine("\t2. Comprar");
                Console.WriteLine("\t3. Ver carrito");
                Console.WriteLine("\t4. Pagar");
                Console.WriteLine("\t5. Salir");
                while (true)
                {
                    String answer = Console.ReadLine();
                    if (answer == "1")
                    {
                        ShowRecipe();
                        break;
                    }
                    else if (answer == "2")
                    {
                        WalkAround();
                        break;
                    }
                    else if (answer == "3")
                    {
                        PrintCart();
                        break;
                    }
                    else if (answer == "4")
                    {
                        Pay();
                        break;
                    }
                    else if (answer == "5")
                    {
                        Environment.Exit(1);
                    }
                }
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            cart   = new List <Product>();
            market = new List <Product>();
            recipe = new List <string>();
            BigSister c1 = new BigSister(Check);

            SupplyStore();
            using (Stream stream = File.Open("data.bin", FileMode.Create, FileAccess.Write, FileShare.None))
            {
                BinaryFormatter bin = new BinaryFormatter();
                bin.Serialize(stream, cart);
            }
            using (StreamReader streamReader = new StreamReader("data.bin"))
            {
                BinaryFormatter binaryFormatter = new BinaryFormatter();
                object          obj             = binaryFormatter.Deserialize(streamReader.BaseStream);
            }
            while (true)
            {
                PrintHeader();
                Console.WriteLine("¿Que quieres hacer?\n");
                Console.WriteLine("\t1. Ver Receta");
                Console.WriteLine("\t2. Comprar");
                Console.WriteLine("\t3. Ver carrito");
                Console.WriteLine("\t4. Pagar");
                Console.WriteLine("\t5. Salir");
                while (true)
                {
                    String answer = Console.ReadLine();
                    if (answer == "1")
                    {
                        ShowRecipe();
                        break;
                    }
                    else if (answer == "2")
                    {
                        WalkAround();
                        c1(recipe, cart[cart.Count - 1]);
                        break;
                    }
                    else if (answer == "3")
                    {
                        PrintCart();
                        break;
                    }
                    else if (answer == "4")
                    {
                        Pay();
                        break;
                    }
                    else if (answer == "5")
                    {
                        using (Stream stream = File.Open("data.bin", FileMode.Create, FileAccess.Write, FileShare.None))
                        {
                            BinaryFormatter bin = new BinaryFormatter();
                            bin.Serialize(stream, cart);
                        }
                        Environment.Exit(1);
                    }
                }
            }
        }