forked from hassan-ibrahim-m/SmartCity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
58 lines (49 loc) · 1.62 KB
/
Program.cs
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
To-Do List:
- Define some cars
- Call RandomTripCreator
- Create an infinite loop to continuoe
*/
using System;
using System.Collections.Generic;
namespace smartcity
{
class Program
{
static void Main(string[] args)
{
Database.cars.Add(new Car(0));
Database.cars.Add(new Car(1));
Database.cars.Add(new Car(2));
Database.cars.Add(new Car(3));
RandomTripCreator.generate(); //create some trips and assign it to the cars
bool traffic_on = false;
for(int i=0;i<Database.cars.Count;i++)
{
if(Database.cars[i].isOnTrip())
{
traffic_on=true;
break;
}
}
while(traffic_on)
{
for(int i=0;i<Database.cars.Count;i++)
{
if(Database.cars[i].isOnTrip())
{
Car car = Database.cars[i];
Trip trip = Database.trips[car.getCurrentTrip()];
//List<Node> getRoute(string mapID, string start, string destination, int tripID)
string mapID = trip.getMapID();
int tripID = trip.getTripID();
string start = trip.getStart();
string destination = trip.getDestination();
car.move(Agent.getRoute(mapID, start, destination, tripID));
}
}
}
}
}
}