Пример #1
0
        /// <summary>
        /// Write the prompt needed to add an item into the database.
        /// </summary>
        private static void WriteAction_Add_To_DB_Item()
        {
            Console.WriteLine("Note that if there is duplicates within the database, then then new entry" +
                              "will replace the old one.");
            Console.Write("Enter the name of your item: ");
            string name = Console.ReadLine();

            Console.Write("Is the item priced by weight? (y/n, n default): ");
            string byWeight = Console.ReadLine();

            Console.Write("Enter the price of the item: ");
            string price = Console.ReadLine();

            bool weighted = false;

            if (byWeight.TrimStart().ToLower()[0] == 'y')
            {
                weighted = true;
            }
            float value = float.Parse(price);

            Database_API.AddItem(name, value, weighted);

            Console.WriteLine("Adding complete.");
        }
Пример #2
0
        public static void BuildData()
        {
            if (!builtItems)
            {
                //Items that sell by weight
                Database_API.AddItem("Beef", 10, true);
                Database_API.AddItem("Chicken", 10, true);
                Database_API.AddItem("Peas", 10, true);

                //Items that sell by unit
                Database_API.AddItem("Soup", 5);
                Database_API.AddItem("Pencils", 6);
                Database_API.AddItem("Carpet", 100);
                Database_API.AddItem("Candy", 4);

                //Items that sell by weight but we actually care about it.
                Database_API.AddItem("Flour", 6, true);

                builtItems = true;
            }

            if (!builtSpecials)
            {
                Database_API.AddSpecial(new SpecialNormal("Soup", 3, Special.DISCOUNT_TYPE.REDUCE_BY_DOLLAR, 3, 3));
                Database_API.AddSpecial(new SpecialNormal("Candy", 2, Special.DISCOUNT_TYPE.REDUCE_BY_DOLLAR, 2, 2));
                Database_API.AddSpecial(new SpecialNormal("Chicken", 50, Special.DISCOUNT_TYPE.REDUCE_BY_PERCENTAGE, 2, 1));

                //Bundling Deals
                Database_API.AddSpecial(new SpecialNormal("Flour", 6, Special.DISCOUNT_TYPE.SET_TO_AMOUNT, 3, 3));

                //Deals with a limit
                Database_API.AddSpecial(new SpecialNormal("Carpet", 60, Special.DISCOUNT_TYPE.REDUCE_BY_DOLLAR, 1, 1, 1));

                //Deals that affect the next item rather than the first one.
                Database_API.AddSpecial(new SpecialDeferred("Beef", 50, Special.DISCOUNT_TYPE.REDUCE_BY_PERCENTAGE, 1));

                builtSpecials = true;
            }
        }