static void Main(string[] args) { List <Product> product = new List <Product>(); MobilePhone mymobile = new MobilePhone(101, "lumia", 90.05, "nokia"); MobilePhone mymobile2 = new MobilePhone(10, "lumia2", 9.05, "nokia"); MobilePhone mymobile3 = new MobilePhone(11, "lumia3", 9.5, "nokia"); Book myBook = new Book(102, "herry potter", 3.0, "DN"); Book myBook2 = new Book(103, "herry potte2", 3.5, "DN"); Book myBook3 = new Book(104, "herry potte3", 3.6, "DN"); //Add ArrayList product.Add(mymobile); product.Add(mymobile2); product.Add(mymobile3); product.Add(myBook); product.Add(myBook2); product.Add(myBook3); //foreach(Product myEach in product) //{ double myComtax = mymobile.computeTax() + mymobile2.computeTax() + mymobile3.computeTax() + myBook.computeTax() + myBook2.computeTax() + myBook3.computeTax(); Console.WriteLine("{0}", myComtax); //} Console.Read(); }
static void Main(string[] args) { double sum; Book book1 = new Book(1, "Code C Sharp 1", 10.5, "FPT1"); Book book2 = new Book(2, "Code C Sharp 2", 12.5, "FPT2"); Book book3 = new Book(3, "Code C Sharp 3", 14.5, "FPT3"); MobilePhone mb1 = new MobilePhone(4, "Nokia 10", 100.5, "Nokia"); MobilePhone mb2 = new MobilePhone(5, "Samsung S20", 200.5, "Samsung"); MobilePhone mb3 = new MobilePhone(5, "Iphone 11", 300.5, "Iphone"); List <Product> product = new List <Product>(); product.Add(book1); product.Add(book2); product.Add(book3); product.Add(mb1); product.Add(mb2); product.Add(mb3); sum = book1.computeTax() + book2.computeTax() + book3.computeTax() + mb1.computeTax() + mb2.computeTax() + mb3.computeTax(); Console.WriteLine("The sum tax is: {0}", sum); Console.ReadLine(); }