コード例 #1
0
        /// <summary>
        /// Method to show manipulation view.
        /// </summary>
        /// <param name="inventoryType">Type of the inventory.</param>
        public static void InventoryManipulationview(string inventoryType)
        {
            Console.WriteLine("\nEnter the Item Name you Want to Edit");
            string itemName = Console.ReadLine();

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

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

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

            EditMenu(inventoryType, itemName);
        }
コード例 #2
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)
        {
            Pulses             pulse          = new Pulses(name, weight, pricePerKG);
            InventoryStructure inventoryTypes = InventoryFactory.ReadJsonFile();

            inventoryTypes.PulsesList.Add(pulse);
            InventoryMngtUtility.WriteToFile(inventoryTypes);
            Console.WriteLine("Added To inventory Succefully");
        }
コード例 #3
0
ファイル: InputForInventory.cs プロジェクト: kaveri1896t/OOPS
        /// <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("\nEnter the Item name you want to remove (All letters in upper case) : ");
                string itemName = Console.ReadLine();
                if (inventoryType.Equals("RICE"))
                {
                    Rice.RemoveRiceObject(itemName);
                }

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

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

                break;
            }
        }
コード例 #4
0
ファイル: InputForInventory.cs プロジェクト: kaveri1896t/OOPS
        /// <summary>
        /// Takes input from user to create objects
        /// </summary>
        /// <param name="inventoryType">inventory Type</param>
        public static void TakeInputsForCreatingObject(string inventoryType)
        {
            string name       = null;
            double weight     = 0;
            double pricePerKG = 0;

            ////Validate name entered by user
            while (true)
            {
                Console.WriteLine("\nEnter the Name for " + inventoryType);
                name = Console.ReadLine();

                if (InventoryMngtUtility.ContainsCharacter(name))
                {
                    Console.WriteLine("\nCharacter not allowed");
                    continue;
                }

                if (InventoryMngtUtility.ContainsDigit(name))
                {
                    Console.WriteLine("\nDigits not allowed");
                    continue;
                }

                if (InventoryMngtUtility.CheckString(name))
                {
                    Console.WriteLine("\nYou should Specify a name");
                    continue;
                }

                break;
            }

            ////Validate weight entered by user
            while (true)
            {
                Console.WriteLine("\nEnter the Weight");
                string stringWeight = Console.ReadLine();

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

            ////Validate price entered by user
            while (true)
            {
                Console.WriteLine("\nSpecify Price per Kg");
                string stringPrice = Console.ReadLine();
                try
                {
                    pricePerKG = Convert.ToDouble(stringPrice);
                    break;
                }
                catch (Exception)
                {
                    Console.WriteLine("\nInvalid Input For Price Per KG");
                    continue;
                }
            }

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

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

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