Пример #1
0
        public static void HandleMainMenuInput(System.ConsoleKey inputKey)
        {
            switch (inputKey)
            {
            case System.ConsoleKey.D1:
                InputOutput.ShowCreateNewShelf();
                break;

            case System.ConsoleKey.D2:
                Shelf.ListShelfs();
                break;

            case System.ConsoleKey.D3:
                Shelf.PlaceItem();
                break;

            case System.ConsoleKey.D4:
                Shelf.RecoverItem();
                break;

            case System.ConsoleKey.D5:
                Environment.Exit(1);
                break;
            }
        }
Пример #2
0
        public static Shelf[] MustNotUseListUseThis(ref Shelf[] shelf)
        {
            if (Engine.shelfCounter > shelf.Length - 2)
            {
                Shelf[] tempShelf = new Shelf[shelf.Length + 10];

                if (shelf.Length > 0)
                {
                    shelf.CopyTo(tempShelf, 0);
                    return(tempShelf);
                }
                return(tempShelf);
            }
            return(shelf);
        }
Пример #3
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();
            //}
        }