static void Main(string[] args) { //creating sellers Seller[] Sellers = new Seller[3]; Sellers[0] = new Seller("Alice", 21); Sellers[1] = new Seller("Bob", 18); Sellers[2] = new Seller("Carl", 26); //creating products Product[] Products = new Product[3]; Products[0] = new Product("Soy Sauce (750 ml)", 11.99, "0001"); Products[1] = new Product("Instant Ramen (500 grams)", 5.50, "0002"); Products[2] = new Product("Instant Ramen (2000 grams)", 19.99, "0003"); //this array contains the number of times each product has been sold int[] product_times_sold = new int[Products.Length]; for (int i = 0; i < product_times_sold.Length; i++) { product_times_sold[i] = 0; } //creating sales Sale[] Sales = new Sale[6]; for (int i = 0; i < 3; i++) { Sales[i] = new Sale(Products[i], Sellers[i], "-"); } //Creating some more sales Sales[3] = new Sale(Products[1], Sellers[0], "-"); Sales[4] = new Sale(Products[1], Sellers[1], "-"); Sales[5] = new Sale(Products[1], Sellers[2], "-"); //processing today's sales double total = 0; Product current_product = new Product(); string cheapest_product_seller = ""; double cheapest_product_price = 0.0; Product most_expensive_product = new Product(); for (int i = 0; i < Sales.Length; i++) { current_product = Sales[i].GetProduct(); //increase the number of times this product has been sold. product_times_sold[GetProductPosition(current_product.GetCode(), Sales)]++; //this keeps track of who sold the cheapest product. if (i == 0 || Sales[i].GetProduct().GetPrice() < cheapest_product_price) { cheapest_product_price = current_product.GetPrice(); cheapest_product_seller = Sales[i].GetSeller().GetName(); } //this keeps track of the most expensive product. if (i == 0 || Sales[i].GetProduct().GetPrice() > most_expensive_product.GetPrice()) { most_expensive_product = current_product; } //add up to total total += Sales[i].GetProduct().GetPrice(); //print product //-----------------{tab}----------------[product name]---------------------[product price] Console.WriteLine($"\t{Sales[i].GetProduct().GetName()} ${Sales[i].GetProduct().GetPrice()}"); } double average_product_price = total / Sales.Length; //Printing system reports //Total Console.WriteLine("Total: $" + Math.Round(total, 2)); //who sold the cheapest item Console.WriteLine($"{cheapest_product_seller} sold the cheapest item."); //average product price Console.WriteLine($"${Math.Round(average_product_price, 2)} " + "is today's average product price."); //most expensive item Console.WriteLine($"{most_expensive_product.GetName()} " + $"[${Math.Round(most_expensive_product.GetPrice(), 2)}] " + "was the most expensive product."); //products and how many times each was sold for (int i = 0; i < Products.Length; i++) { Console.WriteLine($"\t{Products[i].GetName()} was sold {product_times_sold[i]} times."); } }
static void Main(string[] args) { int Total = 0; Store store = new Store(); SalesMan v1 = new SalesMan(); v1.Name = "Carlos"; v1.Age = 30; store.AddSalesMan(v1); SalesMan v2 = new SalesMan(); v2.Name = "Juan"; v2.Age = 30; store.AddSalesMan(v2); SalesMan v3 = new SalesMan(); v3.Name = "Alberto"; v3.Age = 30; store.AddSalesMan(v3); Product p1 = new Product(); p1.Name = "Computer"; p1.Price = 500; store.AddProduc(p1); Product p2 = new Product(); p2.Name = "Keyboard"; p2.Price = 50; store.AddProduc(p2); Product p3 = new Product(); p3.Name = "Monitor"; p3.Price = 100; store.AddProduc(p3); Sale s1 = new Sale(); s1.SalesMan = v1; s1.Product = p1; s1.Comments = "Good seller and great product"; store.AddSale(s1); Sale s4 = new Sale(); s4.SalesMan = v2; s4.Product = p1; s4.Comments = "Good seller and great product"; store.AddSale(s4); Sale s2 = new Sale(); s2.SalesMan = v2; s2.Product = p2; s2.Comments = "Good seller and great product"; store.AddSale(s2); Sale s3 = new Sale(); s3.SalesMan = v3; s3.Product = p3; s3.Comments = "Good seller and great product"; store.AddSale(s3); //Calculate sales total amount Total = p1.Price + p2.Price + p3.Price; System.Console.WriteLine("The total amount of sales is: " + Total); Console.WriteLine("\nProducts"); store.printProducts(); Console.WriteLine("\nSalesMan"); store.printSalesMan(); Console.WriteLine("\nSales"); store.printSales(); Console.WriteLine("\nSales Man That Sold The Cheapest Product: "); store.sellerThatSoldCheapestProduct().salesManStatus(); Console.WriteLine("\nAverage Products Price: "); Console.WriteLine(store.averageProductsPrice()); Console.WriteLine("\nNumber Sells by seller: "); store.printNumberSellsBySalesMan(); Console.WriteLine("\nThe most expensive product: "); store.MostExpensiveProduct().ProductStatus(); }