Exemple #1
0
        static void Main(string[] args)
        {
            Book        book1  = new Book(1, "sach giao khoa", "kim dong", 20000);
            Book        book2  = new Book(2, "sach tieu hoc", "quoc gia", 30000);
            Book        book3  = new Book(3, "sach trung hoc", "quoc gia", 40000);
            MobilePhone phone1 = new MobilePhone(1, "iphone", "apple", 200000);
            MobilePhone phone2 = new MobilePhone(2, "samsung", "han quoc", 300000);
            MobilePhone phone3 = new MobilePhone(3, "galaxy", "han quoc", 400000);

            list.Add(book1);
            list.Add(book2);
            list.Add(book3);
            list.Add(phone1);
            list.Add(phone2);
            list.Add(phone3);
            double sum = 0;

            foreach (Product_class pro in list)

            {
                sum += pro.computeTax();
            }
            Console.WriteLine(sum);
            Console.ReadLine();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            double         result  = 0;
            List <Product> product = new List <Product>();
            MobilePhone    mobile1 = new MobilePhone(1, "Iphone 5", 1.3, "Abc");
            MobilePhone    mobile2 = new MobilePhone(2, "Iphone 6", 2.3, "Abc");
            MobilePhone    mobile3 = new MobilePhone(3, "Iphone 7", 3.3, "Abc");
            Book           book1   = new Book(1, "Sach c#", 8.0, "Sack");
            Book           book2   = new Book(2, "Sach c++", 9.0, "Sack");
            Book           book3   = new Book(2, "Sach c--", 10.0, "Sack");

            product.Add(mobile1);
            product.Add(mobile2);
            product.Add(mobile3);
            product.Add(book1);
            product.Add(book2);
            product.Add(book3);
            foreach (Product item in product)
            {
                result += item.price;
            }
            Console.WriteLine(result);
            Console.ReadKey();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            double         result  = 0;
            List <Product> product = new List <Product>();
            MobilePhone    mobile1 = new MobilePhone(1, "phone1", 10.0, "A");
            MobilePhone    mobile2 = new MobilePhone(2, "phone2", 9.0, "B");
            MobilePhone    mobile3 = new MobilePhone(3, "phone3", 8.0, "C");
            Book           book1   = new Book(1, "book1", 1.0, "AA");
            Book           book2   = new Book(2, "book2", 2.5, "BB");
            Book           book3   = new Book(2, "book3", 3.4, "CC");

            product.Add(mobile1);
            product.Add(mobile2);
            product.Add(mobile3);
            product.Add(book1);
            product.Add(book2);
            product.Add(book3);
            foreach (Product item in product)
            {
                result += item.price;
            }
            Console.WriteLine("Total: " + result);
            Console.ReadKey();
        }