Пример #1
0
        static void Main(string[] args)
        {
            var     random     = new Random();
            var     checkPoint = new CheckPoint();
            Vehicle vehicle;

            do
            {
                Thread.Sleep(random.Next(500, 5001));

                Console.WriteLine();

                var vehicleIndex = random.Next((int)VehicleBodyType.NoVehicle);
                var bodyType     = (VehicleBodyType)vehicleIndex;

                vehicle = VehicleFactory.CreateVehicle(bodyType);

                checkPoint.RegisterCar(vehicle);

                //cp.Statistics.BusesCount = -123;
            } while (!Console.KeyAvailable);

            var statistics = checkPoint.Statistics;

            Console.WriteLine($"Машин проехало: {checkPoint.Statistics.CarsCount}");
            Console.WriteLine(($"Грузовиков проехало: {statistics.TrucksCount}"));
            Console.WriteLine(($"Автобусов проехало: {statistics.BusesCount}"));
            Console.WriteLine(($"Нарушителей скоростного режима: {statistics.SpeedLimitBreakerCount}"));
            Console.WriteLine(($"Машин в угоне: {statistics.CarJackersCount}"));
            Console.WriteLine(($"Средняя скорость: {statistics.AverageSpeed}"));
            Console.ReadKey();
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to my factory!");

            VehicleFactory factory = new VehicleFactory();

            int numberOfWheels = 0;

            Console.Write("Enter number of wheels: ");
            numberOfWheels = Convert.ToInt32(Console.ReadLine());

            while (numberOfWheels > -1)
            {
                Vehicle newVehicle = factory.CreateVehicle("Honda", 2000, "red", numberOfWheels, "General motors");

                Console.WriteLine(newVehicle);

                Console.Write("Enter number of wheels: ");
                numberOfWheels = Convert.ToInt32(Console.ReadLine());
            }

            Console.WriteLine("Good bye!");

            Console.ReadLine();
        }