Пример #1
0
        public static void Test1_requestElevator()
        {
            var battery1 = new Battery(3, 100, 10, 4);

            battery1.columnsList[0].elevatorsList[0].currentFloor = 2;
            battery1.columnsList[0].elevatorsList[0].direction    = "up";
            battery1.columnsList[0].elevatorsList[0].status       = "moving";
            battery1.columnsList[0].elevatorsList[0].queue.AddRange(new List <int>()
            {
                2, 5
            });

            battery1.columnsList[0].elevatorsList[1].currentFloor = 3;
            battery1.columnsList[0].elevatorsList[1].direction    = "down";
            battery1.columnsList[0].elevatorsList[1].status       = "moving";
            battery1.columnsList[0].elevatorsList[1].queue.AddRange(new List <int>()
            {
                3, 5, 8
            });

            battery1.columnsList[0].elevatorsList[2].currentFloor = 38;
            battery1.columnsList[0].elevatorsList[2].direction    = "up";
            battery1.columnsList[0].elevatorsList[2].status       = "moving";
            battery1.columnsList[0].elevatorsList[2].queue.AddRange(new List <int>()
            {
                -1, 3, 6
            });

            battery1.columnsList[0].elevatorsList[3].currentFloor = 38;
            battery1.columnsList[0].elevatorsList[3].direction    = "up";
            battery1.columnsList[0].elevatorsList[3].status       = "moving";
            battery1.columnsList[0].elevatorsList[3].queue.AddRange(new List <int>()
            {
                -1, 5, 8
            });

            battery1.columnsList[1].elevatorsList[0].currentFloor = 5;
            battery1.columnsList[1].elevatorsList[0].direction    = null;
            battery1.columnsList[1].elevatorsList[0].status       = "idle";
            battery1.columnsList[1].elevatorsList[0].queue.AddRange(new List <int>()
            {
            });

            battery1.columnsList[1].elevatorsList[1].currentFloor = 6;
            battery1.columnsList[1].elevatorsList[1].direction    = "up";
            battery1.columnsList[1].elevatorsList[1].status       = "moving";
            battery1.columnsList[1].elevatorsList[1].queue.AddRange(new List <int>()
            {
                1, 2, 3, 4
            });

            battery1.columnsList[1].elevatorsList[2].currentFloor = 7;
            battery1.columnsList[1].elevatorsList[2].direction    = "down";
            battery1.columnsList[1].elevatorsList[2].status       = "moving";
            battery1.columnsList[1].elevatorsList[2].queue.AddRange(new List <int>()
            {
                -3, 2, 7, 8
            });

            battery1.columnsList[1].elevatorsList[3].currentFloor = 7;
            battery1.columnsList[1].elevatorsList[3].direction    = "down";
            battery1.columnsList[1].elevatorsList[3].status       = "moving";
            battery1.columnsList[1].elevatorsList[3].queue.AddRange(new List <int>()
            {
                -3, 2, 7, 8
            });

            battery1.columnsList[2].elevatorsList[0].currentFloor = 6;
            battery1.columnsList[2].elevatorsList[0].direction    = "down";
            battery1.columnsList[2].elevatorsList[0].status       = "moving";
            battery1.columnsList[2].elevatorsList[0].queue.AddRange(new List <int>()
            {
                2, 4
            });

            battery1.columnsList[2].elevatorsList[1].currentFloor = 9;
            battery1.columnsList[2].elevatorsList[1].direction    = null;
            battery1.columnsList[2].elevatorsList[1].status       = "idle";
            battery1.columnsList[2].elevatorsList[1].queue.AddRange(new List <int>()
            {
            });

            battery1.columnsList[2].elevatorsList[2].currentFloor = 38;
            battery1.columnsList[2].elevatorsList[2].direction    = "up";
            battery1.columnsList[2].elevatorsList[2].status       = "moving";
            battery1.columnsList[2].elevatorsList[2].queue.AddRange(new List <int>()
            {
                4, 6, 7
            });

            battery1.columnsList[1].elevatorsList[3].currentFloor = 7;
            battery1.columnsList[1].elevatorsList[3].direction    = "down";
            battery1.columnsList[1].elevatorsList[3].status       = "moving";
            battery1.columnsList[1].elevatorsList[3].queue.AddRange(new List <int>()
            {
                -3, 2, 7, 8
            });

            battery1.requestElevator(9, "up");
        }
Пример #2
0
        static void Main(string[] args)
        {
            // Initialize battery
            var battery = new Battery(4, 5);

            // Test 1 --- Someone at 1st floor requests the 20th floor; Elevator5 (B5) is expected to be sent.
            // Unfold scenario settings & description

            {
                // With second column (or column B) serving floors from 2 to 20, with elevator B1 at 20th
                // floor going to 5th, B2 at 3rd floor going to 15th, B3 at 13th floor going to 1st, B4 at 15th floor
                // going to 2nd, and B5 at 6th floor going to 1st, someone is at 1st floor and requests the 20th floor,
                // Elevator5 (B5) is expected to be sent

                // System.Console.WriteLine("__________________Elevator Status'_________________");
                // Battery.columns[1].elevators[0].currentFloor = 20;
                // Battery.columns[1].elevators[0].currentDirection = "down";
                // System.Console.WriteLine(Battery.columns[1].elevators[0].elev_Id + " on floor " + Battery.columns[1].elevators[0].currentFloor + " going " + Battery.columns[1].elevators[0].currentDirection);

                // Battery.columns[1].elevators[1].currentFloor = 3;
                // Battery.columns[1].elevators[1].currentDirection = "up";
                // System.Console.WriteLine(Battery.columns[1].elevators[1].elev_Id + " on floor " + Battery.columns[1].elevators[1].currentFloor + " going " + Battery.columns[1].elevators[1].currentDirection);

                // Battery.columns[1].elevators[2].currentFloor = 13;
                // Battery.columns[1].elevators[2].currentDirection = "down";
                // System.Console.WriteLine(Battery.columns[1].elevators[2].elev_Id + " on floor " + Battery.columns[1].elevators[2].currentFloor + " going " + Battery.columns[1].elevators[2].currentDirection);

                // Battery.columns[1].elevators[3].currentFloor = 15;
                // Battery.columns[1].elevators[3].currentDirection = "down";
                // System.Console.WriteLine(Battery.columns[1].elevators[3].elev_Id + " on floor " + Battery.columns[1].elevators[3].currentFloor + " going " + Battery.columns[1].elevators[3].currentDirection);

                // Battery.columns[1].elevators[4].currentFloor = 6;
                // Battery.columns[1].elevators[4].currentDirection = "down";
                // System.Console.WriteLine(Battery.columns[1].elevators[4].elev_Id + " on floor " + Battery.columns[1].elevators[4].currentFloor + " going " + Battery.columns[1].elevators[4].currentDirection);
            }
            // Battery.assignElevator(20, "up").operateElevator(20);


            // Test 2 --- Someone at 1st floor requests the 36th floor; Elevator1 (C1) is expected to be sent.
            // Unfold scenario settings & description

            {
                // With third column (or column C) serving floors from 21 to 40, with elevator C1 at 1st
                // floor going to 21th, C2 at 23st floor going to 28th, C3 at 33rd floor going to 1st, C4 at 40th floor
                // going to 24th, and C5 at 39nd floor going to 1st, someone is at 1st floor and requests the 36th floor,
                // Elevator1 (C1) is expected to be sent

                // Battery.columns[2].elevators[0].currentFloor = 0;
                // Battery.columns[2].elevators[0].currentDirection = "up";
                // System.Console.WriteLine(Battery.columns[2].elevators[0].elev_Id + " on floor " + Battery.columns[2].elevators[0].currentFloor + " going " + Battery.columns[2].elevators[0].currentDirection);

                // Battery.columns[2].elevators[1].currentFloor = 23;
                // Battery.columns[2].elevators[1].currentDirection = "up";
                // System.Console.WriteLine(Battery.columns[2].elevators[1].elev_Id + " on floor " + Battery.columns[2].elevators[1].currentFloor + " going " + Battery.columns[2].elevators[1].currentDirection);

                // Battery.columns[2].elevators[2].currentFloor = 33;
                // Battery.columns[2].elevators[2].currentDirection = "down";
                // System.Console.WriteLine(Battery.columns[2].elevators[2].elev_Id + " on floor " + Battery.columns[2].elevators[2].currentFloor + " going " + Battery.columns[2].elevators[2].currentDirection);

                // Battery.columns[2].elevators[3].currentFloor = 40;
                // Battery.columns[2].elevators[3].currentDirection = "down";
                // System.Console.WriteLine(Battery.columns[2].elevators[3].elev_Id + " on floor " + Battery.columns[2].elevators[3].currentFloor + " going " + Battery.columns[2].elevators[3].currentDirection);

                // Battery.columns[2].elevators[4].currentFloor = 39;
                // Battery.columns[2].elevators[4].currentDirection = "down";
                // System.Console.WriteLine(Battery.columns[2].elevators[4].elev_Id + " on floor " + Battery.columns[2].elevators[4].currentFloor + " going " + Battery.columns[2].elevators[4].currentDirection);
            }
            // Battery.assignElevator(36, "up").operateElevator(36);


            // Test 3 --- Someone at 54th floor requests the 1st floor; Elevator1 (D1) is expected to be sent.
            // Unfold scenario settings & description

            {
                // With fourth column (or column D) serving floors from 41 to 60, with elevator D1 at 58th floor
                // going to 1st, D2 at 50th floor going to 60th, D3 at 46th floor going to 58th, D4 at 1st floor going
                // to 54th, and D5 at 60th floor going to 1st, someone is at 54th floor and requests the 1st floor,
                // Elevator1 (D1) is expected to pick him up

                // Battery.columns[3].elevators[0].currentFloor = 58;
                // Battery.columns[3].elevators[0].currentDirection = "down";
                // System.Console.WriteLine(Battery.columns[3].elevators[0].elev_Id + " on floor " + Battery.columns[3].elevators[0].currentFloor + " going " + Battery.columns[3].elevators[0].currentDirection);

                // Battery.columns[3].elevators[1].currentFloor = 50;
                // Battery.columns[3].elevators[1].currentDirection = "up";
                // System.Console.WriteLine(Battery.columns[3].elevators[1].elev_Id + " on floor " + Battery.columns[3].elevators[1].currentFloor + " going " + Battery.columns[3].elevators[1].currentDirection);

                // Battery.columns[3].elevators[2].currentFloor = 46;
                // Battery.columns[3].elevators[2].currentDirection = "up";
                // System.Console.WriteLine(Battery.columns[3].elevators[2].elev_Id + " on floor " + Battery.columns[3].elevators[2].currentFloor + " going " + Battery.columns[3].elevators[2].currentDirection);

                // Battery.columns[3].elevators[3].currentFloor = 0;
                // Battery.columns[3].elevators[3].currentDirection = "up";
                // System.Console.WriteLine(Battery.columns[3].elevators[3].elev_Id + " on floor " + Battery.columns[3].elevators[3].currentFloor + " going " + Battery.columns[3].elevators[3].currentDirection);

                // Battery.columns[3].elevators[4].currentFloor = 60;
                // Battery.columns[3].elevators[4].currentDirection = "down";
                // System.Console.WriteLine(Battery.columns[3].elevators[4].elev_Id + " on floor " + Battery.columns[3].elevators[4].currentFloor + " going " + Battery.columns[3].elevators[4].currentDirection);
            }
            // battery.requestElevator(54, "down").operateElevator(54);


            // Test 4 --- Someone at 1st floor requests the 36th floor; Elevator1 (C1) is expected to be sent.
            // Unfold scenario settings & description

            {
                // With first column (or Column A) serving the basements B1 to B6, with elevator A1 idle at B4, A2
                // idle at 1st floor, A3 at B3 and going to B5, A4 at B6 and going to 1st floor, and A5 at B1 going to
                // B6, someone is at B3 and requests the 1st floor. Elevator A4 is expected to be sent.
                // Elevator4 (A4) is expected to be sent.

                Battery.columns[0].elevators[0].currentFloor     = -4;
                Battery.columns[0].elevators[0].currentDirection = "idle";
                System.Console.WriteLine(Battery.columns[0].elevators[0].elev_Id + " on floor " + Battery.columns[0].elevators[0].currentFloor + " going " + Battery.columns[0].elevators[0].currentDirection);

                Battery.columns[0].elevators[1].currentFloor     = 0;
                Battery.columns[0].elevators[1].currentDirection = "idle";
                System.Console.WriteLine(Battery.columns[0].elevators[1].elev_Id + " on floor " + Battery.columns[0].elevators[1].currentFloor + " going " + Battery.columns[0].elevators[1].currentDirection);

                Battery.columns[0].elevators[2].currentFloor     = -3;
                Battery.columns[0].elevators[2].currentDirection = "down";
                System.Console.WriteLine(Battery.columns[0].elevators[2].elev_Id + " on floor " + Battery.columns[0].elevators[2].currentFloor + " going " + Battery.columns[0].elevators[2].currentDirection);

                Battery.columns[0].elevators[3].currentFloor     = -6;
                Battery.columns[0].elevators[3].currentDirection = "up";
                System.Console.WriteLine(Battery.columns[0].elevators[3].elev_Id + " on floor " + Battery.columns[0].elevators[3].currentFloor + " going " + Battery.columns[0].elevators[3].currentDirection);

                Battery.columns[0].elevators[4].currentFloor     = -1;
                Battery.columns[0].elevators[4].currentDirection = "down";
                System.Console.WriteLine(Battery.columns[0].elevators[4].elev_Id + " on floor " + Battery.columns[0].elevators[4].currentFloor + " going " + Battery.columns[0].elevators[4].currentDirection);
            }
            battery.requestElevator(-3, "up").operateElevator(-3);
        }