示例#1
0
        static void UpdateBasePrice(Pricesheet pricesheet, string item)
        {
            int  length = pricesheet.product.Count;
            bool found  = false;

            for (int i = 0; i < length; i++)
            {
                if (pricesheet.product[i].Contains(item))
                {
                    found = true;
                    Console.WriteLine("What is the new price?");
                    float newPrice = float.Parse(Console.ReadLine());
                    pricesheet.price.Remove(pricesheet.price[i]);
                    pricesheet.price.Insert(i, newPrice);
                }
            }
            if (found == false)
            {
                Console.WriteLine("Item does not exit");
            }
            else if (found == true)
            {
                Console.WriteLine("Price updated");
            }
        }
示例#2
0
 static void Items(Pricesheet pricesheet)
 {
     pricesheet.product.Add("Vanilla");
     pricesheet.price.Add(1);
     pricesheet.product.Add("Chocolate");
     pricesheet.price.Add(2);
     pricesheet.product.Add("Fudge");
     pricesheet.price.Add(3);
     pricesheet.product.Add("Velvet");
     pricesheet.price.Add(4);
 }
示例#3
0
        static void Main(string[] args)
        {
            Pricesheet pricesheet = new Pricesheet();

            Items(pricesheet);

            bool exit = false;

            while (exit == false)
            {
                Console.Clear();
                Console.WriteLine("1. View price sheet before vat.");
                Console.WriteLine("2. View price sheet after vat.");
                Console.WriteLine("3. Update single base price.");
                Console.WriteLine("4. Exit");

                int  choice = int.Parse(Console.ReadLine());
                Menu menu   = new Menu();
                menu = (Menu)choice;

                switch (menu)
                {
                case Menu.BeforeVat:
                    ViewBeforeVat(pricesheet);
                    Console.ReadLine();
                    break;

                case Menu.AfterVat:
                    ViewAfterVat(pricesheet);
                    Console.ReadLine();
                    break;

                case Menu.Update:
                    ViewBeforeVat(pricesheet);
                    Console.WriteLine("\nPlease enter item name to update price:");
                    string item = Console.ReadLine();
                    if (item == "")
                    {
                        Console.WriteLine("Invalid input");
                    }
                    else
                    {
                        UpdateBasePrice(pricesheet, item);
                    }
                    Console.ReadKey();
                    break;

                case Menu.Exit:
                    exit = true;
                    break;
                }
            }
        }
示例#4
0
        static void ViewAfterVat(Pricesheet pricesheet)
        {
            Console.Clear();
            Console.WriteLine("After VAT:\n");
            Console.WriteLine("{0,-15} {1}", "Item:", "Price:");
            Console.WriteLine("-----------------------");
            int    length = pricesheet.product.Count;
            double total  = 0f;

            for (int i = 0; i < length; i++)
            {
                Console.WriteLine("{0,-15} R{1:f2}", pricesheet.product[i], (pricesheet.price[i] + (pricesheet.price[i] * 0.14)));
                total += ((pricesheet.price[i] + (pricesheet.price[i] * 0.14)));
            }
            Console.WriteLine("-----------------------");
            Console.WriteLine("{0,-15} R{1:f2}", "Total", total);
        }