Ejemplo n.º 1
0
        private static void Main(string[] args)
        {
            //Console.BufferWidth
            Console.WriteLine("Enter the distance between checkpoints separated by spaces");
            string str = Console.ReadLine();
            //str = "15 27 16 39 54 75 89 41";
            var checkpoints = (List<int>)StringToList(str);

            Console.WriteLine("Enter the number of cars");
            string carsCountStr = Console.ReadLine();
            int carCount;
            var cars = new List<Car>();
            if (!int.TryParse(carsCountStr, out carCount))
                return;
            //carCount = 3;
            for (int i = 0; i < carCount; i++)
                cars.Add(new Car(5));

            Road road = new Road(checkpoints, cars);
            road.Checkpoint += (sender, eventArgs) => { Console.WriteLine("Checkpoint is {0}", eventArgs.NumberCar); };
            road.Finish += (sender, eventArgs) =>
                                {
                                    Console.WriteLine("Finish is {0}", eventArgs.NumberCar);
                                    Console.ReadLine();
                                    wait = false;
                                };
            road.Start();
            while (wait) ;
        }
Ejemplo n.º 2
0
 public Game()
 {
     car  = new Car(40, 20);
     road = new Road();
 }