コード例 #1
0
        private void Test()
        {
            if (RaceIsOn)
            {
                throw new Exception("Гонка уже началась! Сначала остановите гонку");
            }

            Bolides.AddRange(new List <Bolide>()
            {
                new Bolide("Ferrari", TrackWidth, TrackHeight),
                new Bolide("RedBull", TrackWidth, TrackHeight),
                new Bolide("ForceIndia", TrackWidth, TrackHeight),
                new Bolide("Mercedes", TrackWidth, TrackHeight),
            });
            foreach (Bolide bolide in Bolides)
            {
                Mechanic mechanic = new Mechanic(bolide.Name, bolide);
                mechanic.SetPosition(TrackWidth, TrackHeight);
                Mechanics.Add(mechanic);

                ReparingLoader repaing = new ReparingLoader(bolide.Name, bolide);
                repaing.SetPosition(TrackWidth, TrackHeight);
                Loaders.Add(repaing);

                SafetyCar safety = new SafetyCar(bolide.Name, bolide);
                safety.SetPosition(TrackWidth, TrackHeight);
                Loaders.Add(safety);
            }
        }
コード例 #2
0
        public void AddRacer(string Name)
        {
            if (!RaceIsOn)
            {
                Bolide newbolide = new Bolide(Name, TrackWidth, TrackHeight);
                Bolides.Add(newbolide);

                Mechanic newmechanic = new Mechanic(Name, newbolide);
                newmechanic.SetPosition(TrackWidth, TrackHeight);
                Mechanics.Add(newmechanic);


                ReparingLoader newloader = new ReparingLoader(Name, newbolide);
                newloader.SetPosition(TrackWidth, TrackHeight);
                Loaders.Add(newloader);

                SafetyCar safety = new SafetyCar(Name, newbolide);
                safety.SetPosition(TrackWidth, TrackHeight);
                Loaders.Add(safety);

                SetStartGrid();
            }
            else
            {
                throw new Exception("Гонка уже началась! Сначала остановите гонку");
            }
        }