Пример #1
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);
                    }
                }
            }
        }
Пример #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 ListShelfs()
        {
            Console.Clear();
            int  shelfCount    = Engine.shelfHolder.Length;
            int  currentPage   = 0;
            int  counterSlots  = 0;
            int  availableSlot = 0;
            bool hasPressedEsc = false;

            //Count the pages
            for (int i = 0; i < shelfCount; i++)
            {
                if (Engine.shelfHolder[i] != null)
                {
                    counterSlots += 1;
                }
                if (Engine.shelfHolder[i] == null)
                {
                    continue;
                }
            }


            while (!hasPressedEsc)
            {
                availableSlot = 0;
                if (currentPage >= counterSlots)
                {
                    currentPage -= 1;
                }
                if (currentPage <= -1)
                {
                    currentPage = 0;
                }
                if (Engine.shelfCounter == 0)
                {
                    Console.Clear();
                    Console.WriteLine("There are no shelves.");
                    Console.ReadKey(true);
                    return;
                }

                for (int j = 0; j < Engine.shelfHolder[currentPage].box.GetLength(0); j++)
                {
                    Console.Write("|");
                    for (int k = 0; k < Engine.shelfHolder[currentPage].box.GetLength(1); k++)
                    {
                        if (Engine.shelfHolder[currentPage].box[j, k].desc == null)
                        {
                            Console.Write("   |");
                            availableSlot += 1;
                        }
                        else
                        {
                            Console.Write(" X |");
                        }
                    }
                    Console.WriteLine();
                }

                Console.WriteLine($"{currentPage + 1}({counterSlots})");
                Console.WriteLine();
                Console.WriteLine($"Name: {Engine.shelfHolder[currentPage].name}");
                Console.WriteLine($"Available slots: {availableSlot}");
                Console.WriteLine();
                Console.WriteLine("(<) Previous shelf (>) Next shelf");
                ConsoleKey input = InputOutput.TakeInput();
                switch (input)
                {
                case ConsoleKey.RightArrow:
                    currentPage += 1;
                    Console.Clear();
                    break;

                case ConsoleKey.LeftArrow:
                    currentPage -= 1;
                    Console.Clear();
                    break;

                case ConsoleKey.Escape:
                    hasPressedEsc = true;
                    break;

                default:
                    Console.Clear();
                    break;
                }
            }
        }