Example #1
0
        private void DisplayResult(ICar newCar)
        {
            StringBuilder sb = new StringBuilder();

            var foundedCars = DataSource.GetCars()
                .Where(c => c.Producer == newCar.Producer)
                .Where(c => c.Model == newCar.Model)
                .Where(c => c.EngineType == newCar.EngineType)
                .Where(c => c.Extres.HasAirCondition == newCar.Extres.HasAirCondition)
                .Where(c => c.Extres.HasAlarm == newCar.Extres.HasAlarm)
                .Where(c => c.Extres.HasElectricalGlasses == newCar.Extres.HasElectricalGlasses)
                .ToList();


            for (int i = 0; i < foundedCars.Count; i++)
            {
                sb.AppendLine("<ul><li>Producer: " + foundedCars[i].Producer + "</li>");
                sb.AppendLine("<li>Model: " + foundedCars[i].Model + "</li>");
                sb.AppendLine("<li>Engin Type: " + foundedCars[i].EngineType + "</li>");
                sb.AppendLine("<h6>Extras</h6><ul>");
                sb.AppendLine("<li> HasAirCondition: " + (foundedCars[i].Extres.HasAirCondition ? "Yes" : "No").ToString() + "</li>");
                sb.AppendLine("<li> HasAlarm: " + (foundedCars[i].Extres.HasAlarm ? "Yes" : "No").ToString() + "</li>");
                sb.AppendLine("<li> HasElectricalGlasses: " + (foundedCars[i].Extres.HasElectricalGlasses ? "Yes" : "No").ToString() + "</li></ul></ul>");
                sb.AppendLine("<br/>");
            }

            if (foundedCars.Count == 0)
            {
                this.LiteralContainer.Text = "No results";
            }
            else
            {
                this.LiteralContainer.Text = sb.ToString();
            }
        }
Example #2
0
        /// <summary>
        /// Returns top speed in km/h
        /// </summary>
        /// <param name="sim"></param>
        /// <param name="car"></param>
        /// <returns></returns>
        public double TopSpeed(ISimulator sim, ICar car)
        {
            if (sim.Garage != null && sim.Garage.Available)
            {
                if (car == null)
                {
                    // Look up car.
                    try
                    {
                        car = sim.Garage.SearchCar(sim.Drivers.Player.CarClass, sim.Drivers.Player.CarModel);
                    }catch(Exception ex)
                    {

                    }
                    if (car == null)
                        return TopSpeed_Stock;

                    car.ScanAerodynamics();
                    car.ScanEngine();

                    if (car.Engine == null || car.Aerodynamics == null)
                        return TopSpeed_Stock;
                }

                double power = MaximumPower(sim, car);
                double aero = car.Aerodynamics.GetAerodynamicDrag(sim.Setup);

                return 3.6 * Math.Pow(power * 1000.0 / aero, 1 / 3.0);
            }
            else
            {
                return TopSpeed_Stock;
            }
        }
Example #3
0
 public CarEngineTools(ICar c)
 {
     if (c != null)
     {
         Car = c;
         Car.ScanEngine();
     }
 }
 /// <summary>
 /// 默认构造函数
 /// </summary>
 /// <param name="carService">站点下车辆基础信息接口</param>
 /// <param name="buyService">车辆求购保存读取接口</param>
 /// <param name="accountService">帐号服务接口</param>
 public CarBuyController(ICar carService ,
     IBuyCar buyService,
     IAccountService accountService)
 {
     this.carService = carService;
     this.buyService = buyService;
     this.accountService = accountService;
 }
        public PIDSteeringWheelAngleRegulator(ICar car)
        {
            Car = car;
            regulator = new PIDRegulator(new Settings(), "steering wheel angle regulator");

            car.evTargetSteeringWheelAngleChanged += new TargetSteeringWheelAngleChangedEventHandler(car_evTargetSteeringWheelAngleChanged);
            car.CarComunicator.evSteeringWheelAngleInfoReceived += new SteeringWheelAngleInfoReceivedEventHandler(CarComunicator_evSteeringWheelAngleInfoReceived);
        }
 public CarTransferController(ICar carService,
     ITransferCar buyService,
     IAccountService accountService)
 {
     this.carService = carService;
     this.transferService = buyService;
     this.accountService = accountService;
 }
Example #7
0
		static bool CheckCar(ICar car)
		{
			if (!CheckDriver(car.Driver) | CheckEngine(car.Engine) | !CheckFuel(car.Fuel))
			{
				return false;
			}

			return true;
		}
Example #8
0
        public SimpleBrakeRegulator(ICar car)
        {
            ICar = car;
            regulator = new SimpleRegulator(new Settings(), "brake PID regulator");

            ICar.SpeedRegulator.evNewSpeedSettingCalculated += SpeedRegulator_evNewSpeedSettingCalculated;
            ICar.CarComunicator.evBrakePositionReceived += CarComunicator_evBrakePositionReceived;
            evNewBrakeSettingCalculated += PIDBrakeRegulator_evNewBrakeSettingCalculated;
            ICar.evAlertBrake += ICar_evAlertBrake;
        }
Example #9
0
        MFCSPeedRegulator(ICar car, CarSimulator.CarModel carModel)
        {
            Car = car;
            CarModel = carModel;

            RegisterModelForSteeringEvents();

            ModelThread = new Thread(ContinousCarSimulation);
            ModelThread.Start();
        }
Example #10
0
        public double Drive(ICar car, IRoute route)
        {
            double journeyDuration = 0;

            foreach (IPlace place in route.GetOrderedPlaces())
            {
                IDrivingStrategy drivingStrategy = SelectDrivingStrategy(place);
                journeyDuration += drivingStrategy.Execute(car, place, journeyDuration);
            }
            return journeyDuration;
        }
Example #11
0
        public FakeCarCommunicator(ICar car)
        {
            ICar = car;
            //mFakeThread = new System.Threading.Thread(new ThreadStart(mFakeThreadTasks));
            //mFakeThread.Start();

            model = new CarModel(this);

            communicationThread = new Thread(ContinousCommunication);
            communicationThread.Start();
        }
        public PIDBrakeRegulator(ICar car)
        {
            ICar = car;
            regulator = new PIDRegulator(new Settings(), "brake PID regulator");

            ICar.evTargetSpeedChanged += new TargetSpeedChangedEventHandler(ICar_evTargetSpeedChanged);
            ICar.SpeedRegulator.evNewSpeedSettingCalculated += new NewSpeedSettingCalculatedEventHandler(SpeedRegulator_evNewSpeedSettingCalculated);
            ICar.CarComunicator.evBrakePositionReceived += new BrakePositionReceivedEventHandler(CarComunicator_evBrakePositionReceived);
            evNewBrakeSettingCalculated += new NewBrakeSettingCalculatedEventHandler(PIDBrakeRegulator_evNewBrakeSettingCalculated);
            ICar.evAlertBrake += new EventHandler(ICar_evAlertBrake);
        }
Example #13
0
 /// <summary>
 /// 默认构造函数
 /// </summary>
 /// <param name="site">站点基础信息接口</param>
 /// <param name="channel">一级频道服务接口 配合物品二级列表获取</param>
 /// <param name="car">站点下车辆基础信息接口</param>     
 /// <param name="house">站点下房屋基础信息接口</param>
 public SiteCache(ISite site,
     IChannelService channel,
     ICar car,
     IHouse house)
 {
     this.site = site;
     this.channel = channel;
     this.car = car;
     //this.goods = goods;//因goods 采用二级频道 所以使用IChannelService
     this.house = house;
 }
        public FakeCarCommunicator(ICar car)
        {
            ICar = car;
            //mFakeThread = new System.Threading.Thread(new ThreadStart(mFakeThreadTasks));
            //mFakeThread.Start();

            model = new CarModel(this);

            timer.Interval = TIMER_INTERVAL_IN_MS;
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();
        }
Example #15
0
 public void Upgrade(ICar car)
 {
     var coordinates = new Coordinates(1, 2);
     if (car.Content.ContainsKey(coordinates))
     {
         car.Content[coordinates] = Engine;
     }
     else
     {
         car.Content.Add(coordinates, Engine);
     }
 }
Example #16
0
        public PIDSpeedRegulator(ICar parent)
        {
            Car = parent;
            CarComunicator = parent.CarComunicator;

            regulator = new PIDRegulator(new Settings(), "speed PID regulator");

            Car.evAlertBrake += new EventHandler(Car_evAlertBrake);
            Car.evTargetSpeedChanged += new TargetSpeedChangedEventHandler(Car_evTargetSpeedChanged);
            evNewSpeedSettingCalculated += new NewSpeedSettingCalculatedEventHandler(PIDSpeedRegulator_evNewSpeedSettingCalculated);
            CarComunicator.evSpeedInfoReceived += new SpeedInfoReceivedEventHander(CarComunicator_evSpeedInfoReceived);
        }
 public double Execute(ICar car, IPlace place, double journeyDuration)
 {
     ITrafficLight trafficLight = (ITrafficLight)place;
     double timetaken = 0;
     double waitingTime  = trafficLight.GetWaitingTime(journeyDuration);
     if (waitingTime > 0)
     {
         timetaken += car.Stop();
         timetaken += waitingTime;
         timetaken += car.Start();
     }
     return timetaken;
 }
        public ICarModel GetCarModel(ICar car)
        {
            var carModel = new CarModel
                               {
                                   Color = car.Color,

                                   Id = car.Id,
                                   OptionsMacroText = car.OptionsMacroText,
                                   Price = car.Price.HasValue ? car.Price.Value : 0.00M,
                                   SportsPackage = car.SportsPackage.HasValue ? car.SportsPackage.Value : false,
                                   VehicleModel = car.Model

                               };
            return (ICarModel) carModel;
        }
        public RealCarCommunicator(ICar parent)
        {
            ICar = parent;

            extentionCardCommunicator = new USB4702();
            servoDriver = new ServoDriver();
            angleAndSpeedMeter = new RS232Controller(this);

            //TODO: make thread for every initialization //its actually done for angleAndSpeedMeter
            extentionCardCommunicator.Initialize();
            servoDriver.Initialize();
            angleAndSpeedMeter.Initialize();

            SpeedMeasuringTimer.Interval = SPEED_MEASURING_TIMER_INTERVAL_IN_MS;
            SpeedMeasuringTimer.Tick += new EventHandler(SpeedMeasuringTimer_Tick);
            SpeedMeasuringTimer.Start();
        }
Example #20
0
        /// <summary>
        /// Returns power in HP
        /// </summary>
        /// <param name="sim"></param>
        /// <param name="car"></param>
        /// <returns></returns>
        public double MaximumPower(ISimulator sim, ICar car)
        {
            if (sim.Garage == null)
                return 0;

            if (car == null)
            {
                // Look up car.
                car = sim.Garage.SearchCar(sim.Drivers.Player.CarClass, sim.Drivers.Player.CarModel);

                if (car == null)
                    return 0;

                car.ScanEngine();

                if (car.Engine == null )
                    return 0;
            }

            return car.Engine.GetMaximumPower();
        }
Example #21
0
        public RealCarCommunicator(ICar parent)
        {
            ICar = parent;

            servoDriver = new ServoDriver();
            deviceManager.RegisterDevice(servoDriver);

            //angleAndSpeedMeter = new SafeRS232Controller(this, new SafeRS232Communicator("COM4"));
            //deviceManager.RegisterDevice(angleAndSpeedMeter);

            angleAndSpeedMeter = new CarController_old.RS232Controller(this);
            deviceManager.RegisterDevice(angleAndSpeedMeter);

            extentionCardCommunicator = new USB4702();
            deviceManager.RegisterDevice(extentionCardCommunicator);

            speedometer = new Speedometer(extentionCardCommunicator);
            deviceManager.RegisterDevice(speedometer);

            gearboxController = new GearboxController(extentionCardCommunicator, this);
            deviceManager.RegisterDevice(gearboxController);

            speedometer.evSpeedInfoReceived += speedometer_evSpeedInfoReceived;
        }
Example #22
0
 public Player(ICar car, IPlayerRole role)
 {
     Car = car;
     Role = role;
 }
Example #23
0
 public double Execute(ICar car, IPlace place, double journeyDuration)
 {
     IRoadStretch roadStretch = (IRoadStretch)place;
     return car.Run(roadStretch.GetRoadStretchLength(), roadStretch.GetRoadSpeed());
 }
 public Beach(ICar car)
 {
     Car = car;
 }
Example #25
0
 public void Move(ICar car, string name)
 {
     Console.WriteLine($"{name} broken");
 }
Example #26
0
        private ICar car;//定义一个私有变量保存抽象

        //实现接口
        public void SetCar(ICar car)
        {
            this.car = car;
        }
Example #27
0
 public CarDecorator(ICar car)
 {
     Car = car;
 }
 public void GetNextGridPoint(ITrack track, ICar car, IList <Point> routeGridPoints, Point middleGridPoint, out uint nrBacktracks, out Point gridPoint)
 {
     mComputerDriver.GetNextGridPoint(track, car, routeGridPoints, middleGridPoint, out nrBacktracks, out gridPoint);
 }
 public CarAccessoriesDecorator(ICar car)
 {
     _car = car;
 }
        static void Main(string[] args)
        {
            ToyForKR toyForKR = new ToyForKR();

            //toyForKR.Greet();

            Console.WriteLine();

            ToyForUS toyForUS = new ToyForUS();

            //toyForUS.GreetFirst();

            Console.WriteLine();

            ToyForCN toyForCN = new ToyForCN();

            //toyForCN.GreetForFirst();

            // 인터페이스
            toyForKR.DoGreet();
            toyForUS.DoGreet();
            toyForCN.DoGreet();

            IToy[] Toys = { toyForKR, toyForUS, toyForCN };
            for (int i = 0; i < Toys.Length; i++)
            {
                Toys[i].DoGreet();
            }

            Console.WriteLine();

            // 인터페이스 상속
            Robot robot = new Robot();

            robot.DoWalk();
            robot.DoFly();

            IRobot oldRobot = robot as IRobot;

            oldRobot.DoWalk();
            //oldRobot.DoFly();

            INewGenerationRobot newGenerationRobot = robot as INewGenerationRobot;

            newGenerationRobot.DoWalk();
            newGenerationRobot.DoFly();

            Console.WriteLine();

            // 인터페이스 다중 상속
            MySuperCar mySuperCar = new MySuperCar();

            mySuperCar.DoDriving();
            mySuperCar.DoFlight();

            ICar myCar = mySuperCar as ICar;

            myCar.DoDriving();
            // myCar.DoFlight();

            IAirplane myAirplane = mySuperCar as IAirplane;

            //myAirplane.DoDriving();
            myAirplane.DoFlight();
        }
 public BasicAccessoriesDecorator(ICar aCar) : base(aCar)
 {
 }
Example #32
0
 public HomeController(ILogger <HomeController> logger, ICar car)
 {
     _logger = logger;
     _car    = car;
 }
 public void Reset()
 {
     _car = new ConcreteCar("");
 }
Example #34
0
 public void SetUp()
 {
     _car = Substitute.For<ICar>();
 }
Example #35
0
 public void SelectCar(ICar iCar, ref DataTable datatable)
 {
     _iDataDis.SelectCar(iCar, ref datatable);
 }
Example #36
0
 protected CarDecorator(ICar car)
 {
     Car = car;
 }
 public void Load(ICar car)
 {
     CarEngineTools t = new CarEngineTools(car);
     t.Scan();
     Load(car, t);
 }
Example #38
0
 public Driver(ICar car)
 {
     _car = car;
 }
Example #39
0
 public OfferPrice(ICar car) : base(car)
 {
 }
Example #40
0
 public StreetRacer(string username, ICar car)
     : base(username, "aggressive", 10, car)
 {
 }
Example #41
0
 public CarDecorator(ICar Car)
 {
     car = Car;
 }
 private void PerformCrashTests(ICar car)
 {
     Logger.Write($"Performing crash tests for {car.Name} in FactoryMethod.UkAutomobileShowroom.");
 }
 public CountryRoad(ICar car)
 {
     Car = car;
 }
Example #44
0
 public AttackCar(ICar decoratedCar)
 {
     _decoratedCar = decoratedCar;
 }
Example #45
0
 public HomeController(ICar car)
 {
     _car = car;
 }
 public MultiFunctionalCar3(ICar car, IAirplane airplane)
 {
     _car      = car;
     _airplane = airplane;
 }
 public LittleKingdom(ICar car, IGarage garage)
 {
     Car    = car;
     Garage = garage;
 }
 static void PrintInfo(ICar car)
 {
     Console.WriteLine("Here is a {0} {1} {2} {3}", car.Color.Name, car.Year, car.Make, car.Model);
 }
Example #49
0
 public void InsertCar(ICar iCar)
 {
     _iDataDis.InsertCar(iCar);
 }
Example #50
0
 public ConsoleLoggerDecorator(ICar car, IConsoleLogger logger, int number)
 {
     this.car    = car;
     this.logger = logger;
     this.number = number;
 }
 public DieselCarDecorator(ICar car) : base(car)
 {
 }
Example #52
0
 public abstract void HandlePurchase(ICar purchase);
Example #53
0
        public void DeleteCarFromList(string model)
        {
            ICar car = GetCarFromList(model);

            _carsList.Remove(car);
        }
 private void PerformSafetyChecks(ICar car)
 {
     Logger.Write($"Performing safety checks for {car.Name} in FactoryMethod.UkAutomobileShowroom.");
 }
        public void Load(ICar car, CarEngineTools t)
        {
            if (car != null && car.Engine != null)
            {
                this.BackColor = Color.Black;

                eng = car.Engine;
                tools = t;

                _Settings_mode = 0;
                _Settings_speed = 0;
                _Settings_throttle = 1;

                this.Invalidate();
                cb_mode.Items.Clear();
                cb_mode.DisplayMember = "mode";
                cb_mode.ValueMember = "index";
                foreach (KeyValuePair<int, string> mode in car.Engine.EngineModes)
                {
                    cb_mode.Items.Add(new ucSelectModel_EngineCurve_Mode(mode.Key, mode.Value));
                }

                if (cb_mode.Items.Count >= _Settings_mode)
                    cb_mode.SelectedIndex = _Settings_mode;
            }
        }
Example #56
0
 public CarProxy(Driver driver)
 {
     _driver  = driver;
     _realCar = new Car();
 }
Example #57
0
 public AirConditionner(ICar car) : base(car)
 {
     this.car = car;
 }
Example #58
0
 /// <summary>
 /// 构造方法注入
 /// </summary>
 /// <param name="onecar">传入要注入的对象</param>
 public Person(ICar onecar)
 {
     this.car = onecar;
 }
        private static string SerializeCar(ICar car)
        {
            var jsonObject = JsonObject.Parse(car.ToJson());

            if (jsonObject.ContainsKey("__type"))
                jsonObject.Remove("__type");

            return jsonObject.ToJson();
        }
 public JapanCarFactory(ICar car)
 {
     this.Car = car;
 }