コード例 #1
0
ファイル: Utitlities.cs プロジェクト: freddy212/MyProject
        public static double getTotalPrice()
        {
            double total = 0;

            foreach (var product in ListOfProducts.getListOfProducts())
            {
                total += product.price();
            }
            return(total);
        }
コード例 #2
0
ファイル: Utitlities.cs プロジェクト: freddy212/MyProject
        // If some other requirement arose to have a different html output showing the products,
        //i would refractor this into an interface, with the responsibility of creating the html.
        //I want to create the html severside, because otherwise someone could overwrite the value
        //I want to have a string in my database, instead of a product, as i find this easier to manage.
        // This is possible, because the fields of the products are constants, that don't change
        public static string getProductsInHtml()
        {
            string result = "";

            foreach (var product in ListOfProducts.getListOfProducts())
            {
                result += @"<h3> " + product.productName() + " : You have ordered " + product.getAmount() + " with a cost of: " + product.price() + @" </ h3>";
            }
            return(result);
        }
コード例 #3
0
 public static void clear()
 {
     ListOfProducts.getListOfProducts().Clear();
 }
コード例 #4
0
 public static void addProduct(Product p)
 {
     // Initialize new list, if it is not already created, and add to it.
     ListOfProducts.getListOfProducts().Add(p);
 }