コード例 #1
0
        public void Initialize()
        {
            _sensors = new List<ISensor>();
            _smokeSensor = new SmokeSensor(1);
            _motionSensor = new MotionSensor(2);
            _comms = new CommunicationUnit();
            _powerSupply = new PowerSupply();
            _alarm = new SecurityAlarm();
            _lowBatteryPowerSupply = new PowerSupplyMock(true);
            _commsMock = new CommunicationUnitMock(true);
            _display = new DisplayMock();

            _smokeSensor.SwitchOn();
            _motionSensor.SwitchOn();
            _alarm.SwitchOn();
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            ICollection<ISensor> sensors = new List<ISensor>();
            _smokeSensor = new SmokeSensor(1);
            _motionSensor = new MotionSensor(2);
            var comms = new CommunicationUnit();
            _powerSupply = new PowerSupply();
            _alarm = new SecurityAlarm();

            sensors.Add(_smokeSensor);
            sensors.Add(_motionSensor);

            rbSmokeSensorOn.IsChecked = true;
            rbMotionSensorOn.IsChecked = true;
            rbAlarmOn.IsChecked = true;

            _controller = new SecurityController(sensors, comms,
            _powerSupply, _alarm, userDisplay);
        }