From f1feb13065fc16cd739cd49a83bb6a79b0c4b012 Mon Sep 17 00:00:00 2001 From: vedanthvdev <61700595+vedanthvdev@users.noreply.github.com> Date: Thu, 30 Jul 2020 22:26:17 +0100 Subject: [PATCH 1/6] Changed to local file input to default --- ElevatorAlgorithm/StartMain.cs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ElevatorAlgorithm/StartMain.cs b/ElevatorAlgorithm/StartMain.cs index 003ca6c..765e54d 100644 --- a/ElevatorAlgorithm/StartMain.cs +++ b/ElevatorAlgorithm/StartMain.cs @@ -12,7 +12,9 @@ class StartMain static void Main(string[] args) { //Assigning all default values like minFloor,maxFloor,maxCapacity and number of elevators from a text file - List termsList = new List(); + //this could be used but have to create the file according to the location + + /*List termsList = new List(); String filepath = @"C:\Users\Chint\Desktop\Admin.txt"; List lines = File.ReadAllLines(filepath).ToList(); @@ -25,19 +27,25 @@ static void Main(string[] args) } - //numOfElevators = termsList[0]; - //minFloor = termsList[1]; - //maxFloor = termsList[2]; - //maxCapacity = termsList[3]; + numOfElevators = termsList[0]; + minFloor = termsList[1]; + maxFloor = termsList[2]; + maxCapacity = termsList[3]; + */ + + int numOfElevators = 4; + int minFloor = 0; + int maxFloor = 10; + int maxCapacity = 5; - Elevator[] elevator = new Elevator[termsList[0]]; + Elevator[] elevator = new Elevator[numOfElevators]; // Assigning Lowest Floor //Highest Floor //Maximun Capacity - for (int i = 0; i < termsList[0]; i++) + for (int i = 0; i < numOfElevators; i++) { - elevator[i] = new Elevator(termsList[1], termsList[2], termsList[3]); + elevator[i] = new Elevator(minFloor, maxFloor, maxCapacity); } From ecedf023f78ee9d130a1d34b0056a3bec75d1013 Mon Sep 17 00:00:00 2001 From: vedanthvdev <61700595+vedanthvdev@users.noreply.github.com> Date: Thu, 30 Jul 2020 22:36:50 +0100 Subject: [PATCH 2/6] Changing the file input to default input : minFloor, maxFloor, maxCapacity and num of elevators Changed few comments --- ElevatorAlgorithm/StartMain.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ElevatorAlgorithm/StartMain.cs b/ElevatorAlgorithm/StartMain.cs index 765e54d..d57398e 100644 --- a/ElevatorAlgorithm/StartMain.cs +++ b/ElevatorAlgorithm/StartMain.cs @@ -42,7 +42,8 @@ static void Main(string[] args) // Assigning Lowest Floor //Highest Floor - //Maximun Capacity + //Maximun Capacity + //to all the elevators present for (int i = 0; i < numOfElevators; i++) { elevator[i] = new Elevator(minFloor, maxFloor, maxCapacity); @@ -55,7 +56,7 @@ static void Main(string[] args) while (true) { - //Every Elevator Status + //Status of all Elevators for (int j = 0; j < elevator.Length; j++) { Console.ForegroundColor = ConsoleColor.Cyan; @@ -64,11 +65,11 @@ static void Main(string[] args) Console.ForegroundColor = ConsoleColor.White; } - Console.Out.WriteLine("----------------++++++++-----------------"); - - Console.Out.WriteLine("\nHow many floors are being called "); + Console.Out.WriteLine("--------------------------++++++++-------------------------"); // Checking if the user wants Multiple floors call + Console.Out.WriteLine("\nHow many floors are being called "); + int numFloors = Int32.Parse(Console.ReadLine()); int[] floor = new int[numFloors]; int[] people = new int[numFloors]; @@ -133,7 +134,7 @@ static void Main(string[] args) } LoopEnd: - // Registering the User input of amount of users waiting for on desired floor + // Registering the User input of amount of users waiting on that desired floor while (true) { Console.Out.WriteLine("Enter the NUMBER OF PEOPLE waiting at level " + floor[i] + "----->MAXIMUM " @@ -168,7 +169,7 @@ static void Main(string[] args) // Moving to the selected floor Step by Step change.moveNext(floor[i], z); - // Setting the number of people on the elevator and the elevator selected + // Assigning the number of people boarding the elevator change.setPeople(people[i], z); //Keeps looping until the people on the elevator is 0 From bcefbc42751a186050500e992d74b0aa310bf4ed Mon Sep 17 00:00:00 2001 From: vedanthvdev <61700595+vedanthvdev@users.noreply.github.com> Date: Thu, 30 Jul 2020 22:38:02 +0100 Subject: [PATCH 3/6] Added comments --- ElevatorAlgorithm/StartMain.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/ElevatorAlgorithm/StartMain.cs b/ElevatorAlgorithm/StartMain.cs index d57398e..83c7ebd 100644 --- a/ElevatorAlgorithm/StartMain.cs +++ b/ElevatorAlgorithm/StartMain.cs @@ -33,6 +33,7 @@ static void Main(string[] args) maxCapacity = termsList[3]; */ + //these variables can be changed according to the user int numOfElevators = 4; int minFloor = 0; int maxFloor = 10; From d9a098f0557d4e4f004cba6cdcd8cd47e283ca5d Mon Sep 17 00:00:00 2001 From: vedanthvdev <61700595+vedanthvdev@users.noreply.github.com> Date: Thu, 30 Jul 2020 22:50:25 +0100 Subject: [PATCH 4/6] Changed the question for better understanding --- ElevatorAlgorithm/StartMain.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ElevatorAlgorithm/StartMain.cs b/ElevatorAlgorithm/StartMain.cs index 83c7ebd..9a83f4c 100644 --- a/ElevatorAlgorithm/StartMain.cs +++ b/ElevatorAlgorithm/StartMain.cs @@ -69,7 +69,7 @@ static void Main(string[] args) Console.Out.WriteLine("--------------------------++++++++-------------------------"); // Checking if the user wants Multiple floors call - Console.Out.WriteLine("\nHow many floors are being called "); + Console.Out.WriteLine("\nHOW many MULTIPLE FLOORS are people waiting on?"); int numFloors = Int32.Parse(Console.ReadLine()); int[] floor = new int[numFloors]; From 015299093d9eb4f16fb5fe221fbd63c30d2cb529 Mon Sep 17 00:00:00 2001 From: vedanthvdev <61700595+vedanthvdev@users.noreply.github.com> Date: Fri, 31 Jul 2020 00:15:35 +0100 Subject: [PATCH 5/6] Added the variable text file. To set the default variables by someone who doesnt need to see and understand the code.. --- ElevatorAlgorithm/StartMain.cs | 28 ++++++++++++---------------- ElevatorAlgorithm/Variables.txt | 4 ++++ 2 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 ElevatorAlgorithm/Variables.txt diff --git a/ElevatorAlgorithm/StartMain.cs b/ElevatorAlgorithm/StartMain.cs index 9a83f4c..84ab2d3 100644 --- a/ElevatorAlgorithm/StartMain.cs +++ b/ElevatorAlgorithm/StartMain.cs @@ -14,9 +14,9 @@ static void Main(string[] args) //Assigning all default values like minFloor,maxFloor,maxCapacity and number of elevators from a text file //this could be used but have to create the file according to the location - /*List termsList = new List(); + List termsList = new List(); - String filepath = @"C:\Users\Chint\Desktop\Admin.txt"; + String filepath = @"../../../Variables.txt"; List lines = File.ReadAllLines(filepath).ToList(); foreach(var line in lines){ @@ -26,28 +26,24 @@ static void Main(string[] args) termsList.Add(Int32.Parse(entries[1])); } - - numOfElevators = termsList[0]; - minFloor = termsList[1]; - maxFloor = termsList[2]; - maxCapacity = termsList[3]; - */ - //these variables can be changed according to the user - int numOfElevators = 4; - int minFloor = 0; - int maxFloor = 10; - int maxCapacity = 5; + //these variables can be changed according to the user in Variables.txt file + + //numOfElevators = termsList[0]; + //minFloor = termsList[1]; + //maxFloor = termsList[2]; + //maxCapacity = termsList[3]; + - Elevator[] elevator = new Elevator[numOfElevators]; + Elevator[] elevator = new Elevator[termsList[0]]; // Assigning Lowest Floor //Highest Floor //Maximun Capacity //to all the elevators present - for (int i = 0; i < numOfElevators; i++) + for (int i = 0; i < termsList[0]; i++) { - elevator[i] = new Elevator(minFloor, maxFloor, maxCapacity); + elevator[i] = new Elevator(termsList[1], termsList[2], termsList[3]); } diff --git a/ElevatorAlgorithm/Variables.txt b/ElevatorAlgorithm/Variables.txt new file mode 100644 index 0000000..a1d997b --- /dev/null +++ b/ElevatorAlgorithm/Variables.txt @@ -0,0 +1,4 @@ +NumOfElevators=4 +minFloor=0 +maxFloor=10 +maxCapacity=5 \ No newline at end of file From b67345dbb623e06851de29910f5941a102b365ce Mon Sep 17 00:00:00 2001 From: vedanthvdev <61700595+vedanthvdev@users.noreply.github.com> Date: Fri, 31 Jul 2020 00:17:07 +0100 Subject: [PATCH 6/6] Allignment --- ElevatorAlgorithm/StartMain.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ElevatorAlgorithm/StartMain.cs b/ElevatorAlgorithm/StartMain.cs index 84ab2d3..ec3fcea 100644 --- a/ElevatorAlgorithm/StartMain.cs +++ b/ElevatorAlgorithm/StartMain.cs @@ -2,12 +2,11 @@ using System.IO; using System.Collections.Generic; using System.Linq; -using Microsoft.VisualBasic.CompilerServices; namespace ElevatorAlgorithm { - -class StartMain + + class StartMain { static void Main(string[] args) {