Ejemplo n.º 1
0
        static void Main(string[] args)
        {

            ShoppingList list = new ShoppingList();
            Console.WriteLine("Create ShoppingList");
            int i = 0;
            do {
                Console.WriteLine("1. New product");
                Console.WriteLine("2. Inspect list");
                Console.WriteLine("3. Save list into desktop");
                Console.WriteLine("4. Go shopping");
                int menu = int.Parse(Console.ReadLine());                                
                switch (menu)
                {
                    case 1:
                        {
                            Product product = new Product();
                            Console.WriteLine("Name: ");
                            string name = Console.ReadLine();
                            product.Name = name;
                            Console.WriteLine("Value: ");
                            double value = double.Parse(Console.ReadLine());
                            product.Value = value;
                            list.AddProduct(product);
                            break;
                        }
                    case 2:
                        {
                            Console.WriteLine("Your list contains: ");
                            list.ShowList();
                            break;
                        }
                    case 3:
                        {
                            list.SaveList();
                            Console.WriteLine("Saved!");
                            break;
                        }
                    case 4:
                        {
                            Console.WriteLine("Bye!");
                            i = 1;
                            break;
                        }
                }

               } while (i == 0);



        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Products cart = new Products();

            Product product1 = new Product { Name = "Milk", Price = 1.05 };
            Product product2 = new Product { Name = "Bread", Price = 1.95 };
            Product product3 = new Product { Name = "Butter", Price = 2.25 };

            cart.AddProduct(product1);
            cart.AddProduct(product2);
            cart.AddProduct(product3);

            cart.Print();
        }
Ejemplo n.º 3
0
 public void AddProduct(Product product)
 {
     products.Add(product);
 }
Ejemplo n.º 4
0
 public void AddProduct(Product product)
 {
     list.Add(product);
 }