Exemplo n.º 1
0
        /// <summary>
        /// Takes Input necessary for Removing a object from inventory.
        /// </summary>
        /// <param name="inventoryType">inventory type</param>
        public static void TakeInputForRemovingObject(string inventoryType)
        {
            while (true)
            {
                Console.WriteLine("Enter the Item name you want to remove");
                string itemName = Console.ReadLine();

                if (!Regex.IsMatch(itemName, "^[a-zA-Z]+$"))
                {
                    Console.WriteLine("Invalid input ");
                    continue;
                }

                if (inventoryType.Equals("RICE"))
                {
                    RiceClass.RemoveRiceObject(itemName);
                }

                if (inventoryType.Equals("WHEAT"))
                {
                    WheatClass.RemoveWheatObject(itemName);
                }

                if (inventoryType.Equals("PULSES"))
                {
                    PulsesClass.RemovePulseObject(itemName);
                }

                break;
            }
        }
        /// <summary>
        /// Inventories the manipulation view.
        /// </summary>
        /// <param name="inventoryType">Type of the inventory.</param>
        public static void InventoryManipulationview(string inventoryType)
        {
            Console.WriteLine("Enter the Item Name you Want to Edit");
            string itemName = Console.ReadLine();

            if (inventoryType.Equals("RICE"))
            {
                if (RiceClass.DoesObjectExist(itemName) == false)
                {
                    Console.WriteLine("item " + itemName + " does not exist");
                    return;
                }
            }

            if (inventoryType.Equals("WHEAT"))
            {
                if (WheatClass.DoesObjectExist(itemName) == false)
                {
                    Console.WriteLine("item " + itemName + " does not exist");
                    return;
                }
            }

            if (inventoryType.Equals("PULSES"))
            {
                if (PulsesClass.DoesObjectExist(itemName) == false)
                {
                    Console.WriteLine("item " + itemName + " does not exist");
                    return;
                }
            }

            EditMenu(inventoryType, itemName);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the pulses object.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="weight">The weight.</param>
        /// <param name="pricePerKG">The price per kg.</param>
        public static void CreatePulsesObject(string name, double weight, double pricePerKG)
        {
            PulsesClass    pulse          = new PulsesClass(name, weight, pricePerKG);
            InventoryTypes inventoryTypes = InventoryFactory.ReadJsonFile();

            inventoryTypes.PulsesList.Add(pulse);
            WriteToFile.WriteDataToFile(inventoryTypes);
            Console.WriteLine("Added To inventory Succefully");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Takes input
        /// </summary>
        /// <param name="inventoryType">inventory Type</param>
        public static void TakeInputsForCreatingObject(string inventoryType)
        {
            string name       = null;
            double weight     = 0;
            double pricePerKG = 0;

            while (true)
            {
                Console.WriteLine("Enter the Name for " + inventoryType);
                name = Console.ReadLine();

                if (Utility.ContainsCharacter(name))
                {
                    Console.WriteLine("No Character Allowed");
                    continue;
                }

                if (Utility.ContainsDigit(name))
                {
                    Console.WriteLine("No Digits Allowed");
                    continue;
                }

                if (Utility.CheckString(name))
                {
                    Console.WriteLine("You should Specify a name");
                    continue;
                }

                break;
            }

            while (true)
            {
                Console.WriteLine("Enter the Weight");
                string stringWeight = Console.ReadLine();

                try
                {
                    weight = Convert.ToDouble(stringWeight);
                    break;
                }
                catch (Exception)
                {
                    Console.WriteLine("Invalid Input For Weight");
                    continue;
                }
            }

            while (true)
            {
                Console.WriteLine("Specify Price per Kg");
                string stringPrice = Console.ReadLine();
                try
                {
                    pricePerKG = Convert.ToDouble(stringPrice);
                    break;
                }
                catch (Exception)
                {
                    Console.WriteLine("Invalid Input For Price Per KG");
                    continue;
                }
            }

            //// Checks For Which Inventory Item Object should be created.
            if (inventoryType.Equals("RICE"))
            {
                RiceClass.CreateRiceObject(name, weight, pricePerKG);
            }

            //// Checks For Which Inventory Item Object should be created.
            if (inventoryType.Equals("WHEAT"))
            {
                WheatClass.CreateWheatObject(name, weight, pricePerKG);
            }

            //// Checks For Which Inventory Item Object should be created.
            if (inventoryType.Equals("PULSES"))
            {
                PulsesClass.CreatePulsesObject(name, weight, pricePerKG);
            }
        }