Пример #1
0
        /// <summary>
        /// Inventeries the manupulation view.
        /// </summary>
        /// <param name="inventeryType">Type of the inventery.</param>
        public static void InventeryManupulationView(string inventeryType)
        {
            Console.WriteLine("please enter the item you want to edit");
            string name = Console.ReadLine();

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

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

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

            EditMenu(inventeryType, name);
        }
Пример #2
0
        /// <summary>
        /// Takes the input for removing object.
        /// </summary>
        /// <param name="inventeryTypes">The inventery types.</param>
        public static void TakeInputForRemovingObject(string inventeryTypes)
        {
            while (true)
            {
                Console.WriteLine("please enter the name, that you want to remove");
                string name = Console.ReadLine();
                if (!Regex.IsMatch(name, "^[a-zA-Z]+$"))
                {
                    Console.WriteLine("invalid input");
                    continue;
                }

                if (inventeryTypes.Equals("RICE"))
                {
                    RiceClass.RemoveRiceObject(name);
                }

                if (inventeryTypes.Equals("WHEAT"))
                {
                    WheatClass.RemoveWheatObject(name);
                }

                if (inventeryTypes.Equals("PULSES"))
                {
                    PulsesClass.RemovePulsesObject(name);
                }

                break;
            }
        }
Пример #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    pulses         = new PulsesClass(name, weight, pricePerKg);
            InventeryTypes inventeryTypes = InventeryFactory.ReadJsonFile();

            inventeryTypes.PulsesList.Add(pulses);
            WriteToFile.WriteDataToFile(inventeryTypes);
            Console.WriteLine("added data to inventory successfully");
        }
Пример #4
0
        /// <summary>
        /// Takes the inputs for creating objects.
        /// </summary>
        /// <param name="inventeryTypes">The inventery types.</param>
        public static void TakeInputsForCreatingObjects(string inventeryTypes)
        {
            string name       = null;
            double weight     = 0.0;
            double pricePerKg = 0.0;

            while (true)
            {
                Console.WriteLine("please enter the name for " + inventeryTypes);
                name = Console.ReadLine();
                if (Utility.ContainsCharacter(name))
                {
                    Console.WriteLine("no character allowed");
                    continue;
                }

                if (!Utility.ContainsDigit(name))
                {
                    Console.WriteLine("digits not allowed ");
                    continue;
                }

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

                break;
            }

            while (true)
            {
                Console.WriteLine("plase enter the weight");
                string stringWeight = Console.ReadLine();
                try
                {
                    weight = Convert.ToDouble(stringWeight);
                    break;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + "invalid input for weight");
                }
            }

            while (true)
            {
                Console.WriteLine("plaese enter the price");
                string stringPrice = Console.ReadLine();
                try
                {
                    pricePerKg = Convert.ToDouble(stringPrice);
                    break;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message + "input is not valid");
                }
            }

            if (inventeryTypes.Equals("RICE"))
            {
                RiceClass.CreateObjectOfRice(name, weight, pricePerKg);
            }

            if (inventeryTypes.Equals("WHEAT"))
            {
                WheatClass.CreateWheatObject(name, weight, pricePerKg);
            }

            if (inventeryTypes.Equals("PULSES"))
            {
                PulsesClass.CreatePulsesObject(name, weight, pricePerKg);
            }
        }