-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (33 loc) · 1.39 KB
/
Program.cs
File metadata and controls
39 lines (33 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
internal class Program
{
private static void Main(string[] args)
{
// making a list person objects, called people, to store the csv data
List<Person> people = new List<Person>();
// file path:
string filePath = "/Users/Berna/Documents/LiftAlgorithm/Data/DataInput.csv";
using ( var data = new StreamReader(filePath))
{
// skipping the header line
data.ReadLine();
// parse remaining lines and make person object
while(!data.EndOfStream) // if it is not the end of the file, do below:
{
var line = data.ReadLine(); // read each line and store as 'line'
var valuesOfColumns = line.Split(','); // split at each ',' and store as 'valuesOfColumns'
var person = new Person
{
Id = int.Parse(valuesOfColumns[0]),
FromFloor = int.Parse(valuesOfColumns[1]),
DestinationFloor = int.Parse(valuesOfColumns[2]),
CallTime = int.Parse(valuesOfColumns[3])
};
people.Add(person);
}
}
Lift lift = new Lift(people);
// running the LiftController:
LiftController liftController = new LiftController(people);
liftController.ProcessCalls();
}
}