コード例 #1
0
        static void Main(string[] args)
        {
            // Scenario 1
            void Scenario1()
            {
                Console.WriteLine("******************* ******************* *******************");
                Console.WriteLine("*******************      Scenario 1     *******************");
                Console.WriteLine("******************* ******************* *******************");
                Battery Battery1 = new Battery(4, 66, 6, 5);

                // Initializing Elevator 1 of Column 2
                Battery1.columnList[1].elevatorList[0].Position  = 20;
                Battery1.columnList[1].elevatorList[0].Direction = "DOWN";
                Battery1.columnList[1].elevatorList[0].StopList.Add(5);
                // Initializing Elevator 2 of Column 2
                Battery1.columnList[1].elevatorList[1].Position  = 2;
                Battery1.columnList[1].elevatorList[1].Direction = "UP";
                Battery1.columnList[1].elevatorList[1].StopList.Add(15);
                // // Initializing Elevator 3 of Column 2
                Battery1.columnList[1].elevatorList[2].Position  = 13;
                Battery1.columnList[1].elevatorList[2].Direction = "DOWN";
                Battery1.columnList[1].elevatorList[2].StopList.Add(1);
                // // Initializing Elevator 4 of Column 2
                Battery1.columnList[1].elevatorList[3].Position  = 15;
                Battery1.columnList[1].elevatorList[3].Direction = "DOWN";
                Battery1.columnList[1].elevatorList[3].StopList.Add(2);
                // // Initializing Elevator 5 of Column 2
                Battery1.columnList[1].elevatorList[4].Position  = 6;
                Battery1.columnList[1].elevatorList[4].Direction = "DOWN";
                Battery1.columnList[1].elevatorList[4].StopList.Add(1);
                Console.WriteLine("******************* ******************* *******************");
                Console.WriteLine("******** User at floor 1. He goes UP to floor 20 ********");
                Console.WriteLine("*********** Elevator 5 from Column 2 is expected **********");
                Console.WriteLine("******************* ******************* *******************");
                Battery1.AssignElevator(20);
            }

            // Scenario 2
            void Scenario2()
            {
                Console.WriteLine("******************* ******************* *******************");
                Console.WriteLine("*******************      Scenario 2     *******************");
                Console.WriteLine("******************* ******************* *******************");
                Battery Battery2 = new Battery(4, 66, 6, 5);

                // Initializing Elevator 1 of Column 3
                Battery2.columnList[2].elevatorList[0].Position  = 1;
                Battery2.columnList[2].elevatorList[0].Direction = "UP";
                Battery2.columnList[2].elevatorList[0].StopList.Add(21);
                // Initializing Elevator 2 of Column 3
                Battery2.columnList[2].elevatorList[1].Position  = 23;
                Battery2.columnList[2].elevatorList[1].Direction = "UP";
                Battery2.columnList[2].elevatorList[1].StopList.Add(28);
                // // Initializing Elevator 3 of Column 3
                Battery2.columnList[2].elevatorList[2].Position  = 33;
                Battery2.columnList[2].elevatorList[2].Direction = "DOWN";
                Battery2.columnList[2].elevatorList[2].StopList.Add(1);
                // // Initializing Elevator 4 of Column 3
                Battery2.columnList[2].elevatorList[3].Position  = 40;
                Battery2.columnList[2].elevatorList[3].Direction = "DOWN";
                Battery2.columnList[2].elevatorList[3].StopList.Add(24);
                // // Initializing Elevator 5 of Column 3
                Battery2.columnList[2].elevatorList[4].Position  = 39;
                Battery2.columnList[2].elevatorList[4].Direction = "DOWN";
                Battery2.columnList[2].elevatorList[4].StopList.Add(1);
                Console.WriteLine("******************* ******************* *******************");
                Console.WriteLine("******** User at floor 1. He goes UP to floor 36 ********");
                Console.WriteLine("*********** Elevator 1 from Column 3 is expected **********");
                Console.WriteLine("******************* ******************* *******************");
                Battery2.AssignElevator(36);
            }

            // Scenario 3
            void Scenario3()
            {
                Console.WriteLine("******************* ******************* *******************");
                Console.WriteLine("*******************      Scenario 3     *******************");
                Console.WriteLine("******************* ******************* *******************");
                Battery Battery3 = new Battery(4, 66, 6, 5);

                // Initializing Elevator 1 of Column 3
                Battery3.columnList[3].elevatorList[0].Position  = 58;
                Battery3.columnList[3].elevatorList[0].Direction = "DOWN";
                Battery3.columnList[3].elevatorList[0].StopList.Add(1);
                // Initializing Elevator 2 of Column 3
                Battery3.columnList[3].elevatorList[1].Position  = 50;
                Battery3.columnList[3].elevatorList[1].Direction = "UP";
                Battery3.columnList[3].elevatorList[1].StopList.Add(60);
                // // Initializing Elevator 3 of Column 3
                Battery3.columnList[3].elevatorList[2].Position  = 46;
                Battery3.columnList[3].elevatorList[2].Direction = "UP";
                Battery3.columnList[3].elevatorList[2].StopList.Add(58);
                // // Initializing Elevator 4 of Column 3
                Battery3.columnList[3].elevatorList[3].Position  = 1;
                Battery3.columnList[3].elevatorList[3].Direction = "UP";
                Battery3.columnList[3].elevatorList[3].StopList.Add(54);
                // // Initializing Elevator 5 of Column 3
                Battery3.columnList[3].elevatorList[4].Position  = 60;
                Battery3.columnList[3].elevatorList[4].Direction = "DOWN";
                Battery3.columnList[3].elevatorList[4].StopList.Add(1);
                // Battery3.AssignElevator();
                Console.WriteLine("******************* ******************* *******************");
                Console.WriteLine("******** User at floor 54. He goes DOWN to floor 1 ********");
                Console.WriteLine("*********** Elevator 1 from Column 4 is expected **********");
                Console.WriteLine("******************* ******************* *******************");
                Battery3.RequestElevator(54);
            }

            // Scenario 4
            void Scenario4()
            {
                Console.WriteLine("******************* ******************* *******************");
                Console.WriteLine("*******************      Scenario 4     *******************");
                Console.WriteLine("******************* ******************* *******************");
                Battery Battery4 = new Battery(4, 66, 6, 5);

                // Initializing Elevator 1 of Column 4
                Battery4.columnList[0].elevatorList[0].Position  = -4;
                Battery4.columnList[0].elevatorList[0].Direction = "IDLE";
                // Battery4.columnList[0].elevatorList[0].StopList.Add(1);
                // Initializing Elevator 2 of Column 4
                Battery4.columnList[0].elevatorList[1].Position  = 1;
                Battery4.columnList[0].elevatorList[1].Direction = "IDLE";
                // Battery4.columnList[0].elevatorList[1].StopList.Add();
                // // Initializing Elevator 3 of Column 4
                Battery4.columnList[0].elevatorList[2].Position  = -3;
                Battery4.columnList[0].elevatorList[2].Direction = "DOWN";
                Battery4.columnList[0].elevatorList[2].StopList.Add(-5);
                // // Initializing Elevator 4 of Column 4
                Battery4.columnList[0].elevatorList[3].Position  = -6;
                Battery4.columnList[0].elevatorList[3].Direction = "UP";
                Battery4.columnList[0].elevatorList[3].StopList.Add(1);
                // // Initializing Elevator 5 of Column 4
                Battery4.columnList[0].elevatorList[4].Position  = -1;
                Battery4.columnList[0].elevatorList[4].Direction = "DOWN";
                Battery4.columnList[0].elevatorList[4].StopList.Add(-6);
                // Battery3.AssignElevator();
                Console.WriteLine("******************* ******************* *******************");
                Console.WriteLine("********* User at floor -3. He goes UP to floor 1 *********");
                Console.WriteLine("*********** Elevator 4 from Column 1 is expected **********");
                Console.WriteLine("******************* ******************* *******************");
                Battery4.RequestElevator(-3);
            }

            Scenario1();
            Scenario2();
            Scenario3();
            Scenario4();
            // Console.ReadKey();
        }