Пример #1
0
        public static void PlaceItem()
        {
            Console.Clear();
            Console.WriteLine("Shelf ID:");
            Console.WriteLine("Row:");
            Console.WriteLine("Column:");
            Console.WriteLine("Content");
            Console.SetCursorPosition(11, 0);
            int shelfIdInput = InputOutput.TakeInputNumber();

            Console.SetCursorPosition(6, 1);
            int shelfRow = InputOutput.TakeInputNumber();

            Console.SetCursorPosition(9, 2);
            int shelfCol = InputOutput.TakeInputNumber();

            Console.SetCursorPosition(10, 3);
            string shelfContent = Console.ReadLine();

            for (int i = 0; i < Engine.shelfHolder.Length; i++)
            {
                if (Engine.shelfHolder[i] == null)
                {
                    continue;
                }
                if (shelfIdInput == Engine.shelfHolder[i].id)
                {
                    if (shelfRow > Engine.shelfHolder[i].box.GetLength(0) || shelfCol > Engine.shelfHolder[i].box.GetLength(1))
                    {
                        Console.Clear();
                        Console.WriteLine($"You attempted to place your item *{shelfContent}* out of bounds");
                        Console.ReadKey();
                        return;
                    }
                    if (Engine.shelfHolder[i].box[shelfRow - 1, shelfCol - 1].desc == null)
                    {
                        Engine.shelfHolder[i].box[shelfRow - 1, shelfCol - 1].desc = shelfContent;
                        Console.Clear();
                        Console.WriteLine("Package placed");
                        Console.ReadKey();
                        return;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Slot occupied");
                        Console.ReadLine();
                        return;
                    }
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("No Shelf was found with that ID");
                    Console.ReadLine();
                    return;
                }
            }
        }
Пример #2
0
        public static void ShowCreateNewShelf()
        {
            Console.Clear();
            Console.Write(String.Format("{3} \n{0} \n {1} \n {2} ", nameString, rowString, colString, idString));

            Console.SetCursorPosition(idString.Length + 2, 0);
            int shelfId = InputOutput.TakeInputNumber();

            if (shelfId == -1)
            {
                return;
            }

            Console.SetCursorPosition(nameString.Length + 2, 1);
            string shelfName = Console.ReadLine();

            Console.SetCursorPosition(rowString.Length + 2, 2);
            int shelfRow = InputOutput.TakeInputNumber();

            if (shelfRow == -1)
            {
                return;
            }

            Console.SetCursorPosition(colString.Length + 2, 3);
            int shelfCol = InputOutput.TakeInputNumber();

            if (shelfCol == -1)
            {
                return;
            }

            for (int i = 0; i < Engine.shelfHolder.GetLength(0); i++)
            {
                if (Engine.shelfHolder[i] == null)
                {
                    continue;
                }
                if (Engine.shelfHolder[i].id == shelfId)
                {
                    Console.Clear();
                    Console.WriteLine("A shelf already exists with that ID");
                    Console.ReadKey();
                    return;
                }
            }

            /*if (shelfRow == -1 || shelfCol == -1)
             * {
             *  Console.WriteLine("Please Try Again");
             *  Console.ReadKey();
             *
             * }
             *
             * else
             * {*/

            Shelf newShelf = new Shelf(shelfName, shelfCol, shelfRow, shelfId);

            Console.Clear();
            Console.WriteLine("Shelf successfully created");
            Console.ReadKey();
            //}
        }
Пример #3
0
        public static void RecoverItem()
        {
            Console.Clear();
            Console.WriteLine("Shelf ID:");
            Console.WriteLine("Row:");
            Console.WriteLine("Column:");

            Console.SetCursorPosition(11, 0);
            int shelfIdInput = InputOutput.TakeInputNumber();

            Console.SetCursorPosition(6, 1);
            int shelfRow = InputOutput.TakeInputNumber();

            Console.SetCursorPosition(9, 2);
            int shelfCol = InputOutput.TakeInputNumber();

            for (int i = 0; i < Engine.shelfHolder.Length; i++)
            {
                if (Engine.shelfHolder[i] == null)
                {
                    continue;
                }

                if (shelfIdInput == Engine.shelfHolder[i].id)
                {
                    continue;
                }
                else
                {
                    Console.Clear();
                    Console.WriteLine("No Shelf was found with that ID");
                    Console.ReadLine();
                    return;
                }
            }



            for (int i = 0; i < Engine.shelfHolder.Length; i++)
            {
                if (Engine.shelfHolder[i] == null)
                {
                    return;
                }
                if (shelfIdInput == Engine.shelfHolder[i].id)
                {
                    if (shelfRow >= Engine.shelfHolder[i].box.GetLength(0) + 1 || shelfCol >= Engine.shelfHolder[i].box.GetLength(1) + 1)
                    {
                        Console.WriteLine("You tried to access a box out of bounds");
                        Console.WriteLine("<Press any key to continue>");
                        Console.ReadKey(true);
                        return;
                    }
                    if (Engine.shelfHolder[i].box[shelfRow - 1, shelfCol - 1].desc == null)
                    {
                        Console.Clear();
                        Console.WriteLine("Slot empty");
                        Thread.Sleep(2000);

                        return;
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine($"Package successfully retrieved\nContent: {Engine.shelfHolder[i].box[shelfRow - 1, shelfCol - 1].desc}");
                        Engine.shelfHolder[i].box[shelfRow - 1, shelfCol - 1].desc = null;
                        Console.WriteLine("<Press any key to continue>");
                        Console.ReadKey(true);
                    }
                }
            }
        }