Пример #1
0
 private void CheckForDuplicateEntry(IAirConditioner airConditioner)
 {
     if (this.data.AirConditioners.ContainsKey(airConditioner.Manufacturer + airConditioner.Model))
     {
         throw new DuplicateEntryException(Constants.Duplicate);
     }
 }
        public string TestAirConditioner(string manufacturer, string model)
        {
            IAirConditioner airConditioner = this.Database.AirConditioners.GetItem(manufacturer, model);
            var             mark           = airConditioner.Test() ? Mark.Passed : Mark.Failed;

            this.Database.Reports.Add(new Report(airConditioner.Manufacturer, airConditioner.Model, mark));
            return(string.Format(Constants.TestAirConditioner, model, manufacturer));
        }
        public void AddAirConditioner(IAirConditioner airConditioner)
        {
            if (this.AirConditioners.ContainsKey(airConditioner.Model))
            {
                throw new DuplicateEntryException(Messages.DuplicateEntry);
            }

            this.AirConditioners.Add(airConditioner.Model, airConditioner);
        }
Пример #4
0
        public void AddAirConditioner(IAirConditioner airConditioner)
        {
            if (GetAirConditioner(airConditioner.Manufacturer, airConditioner.Model) != null)
            {
                throw new DuplicateEntryException(Constants.DUPLICATE);
            }

            AirConditioners.Add(airConditioner);
        }
        public void AddAirConditioner(IAirConditioner airConditioner)
        {
            if (this.AirConditioners.ContainsKey(airConditioner.Model))
            {
                throw new DuplicateEntryException(Messages.DuplicateEntry);
            }

            this.AirConditioners.Add(airConditioner.Model, airConditioner);
        }
        public void AddAirConditioner(IAirConditioner airConditioner)
        {
            if (GetAirConditioner(airConditioner.Manufacturer, airConditioner.Model) != null)
            {
                throw new DuplicateEntryException(Constants.DUPLICATE);
            }

            AirConditioners.Add(airConditioner);
        }
Пример #7
0
        public void AddAirConditioner(IAirConditioner airConditioner)
        {
            if (airConditioner == null)
            {
                throw new ArgumentNullException("Air conditioner cannot be null");
            }

            this.airConditioners.Add(airConditioner);
        }
        /// <summary>
        /// A method used to search through the database in order to find
        /// an air conditioner by manufacturer and model
        /// </summary>
        /// <param name="manufacturer">The manufacturer you would be searching for</param>
        /// <param name="model"> The model that you would be searching for</param>
        /// <returns>returns a string with the specifications of the found device</returns>
        public string FindAirConditioner(string manufacturer, string model)
        {
            IAirConditioner airConditioner = database.GetAirConditioner(manufacturer, model);

            if (airConditioner == null)
            {
                throw new NonExistantEntryException();
            }
            return(airConditioner.ToString());
        }
Пример #9
0
 private void CheckIfExist(IAirConditioner airConditioner)
 {
     foreach (var air in data.AirConditioners)
     {
         if (air.Manufacturer == airConditioner.Manufacturer &&
             air.Model == airConditioner.Model)
         {
             throw new DuplicateEntryException("An entry for the given model already exists.");
         }
     }
 }
Пример #10
0
 public void FindAirConditioner(string manufacturer, string model)
 {
     try
     {
         IAirConditioner airConditioner = data.GetAirConditioner(manufacturer, model);
         writer.WriteLine(airConditioner.ToString());
     }
     catch (NullReferenceException)
     {
         writer.WriteLine("The specified entry does not exist.");
     }
 }
Пример #11
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="VoiceControlledAirConditioner"/> class.
        /// </summary>
        /// <param name="airConditioner">
        ///     The instance of the air conditioner to control by the voice commands.
        /// </param>
        /// <param name="speechRecognition">
        ///     An instance of the in-process speech recognition engine.
        /// </param>
        /// <param name="speechSynthesizer">
        ///     An instance of the speech synthesizer, to output vocal responses to the user.
        /// </param>
        /// <param name="logger"> The logger. </param>
        public VoiceControlledAirConditioner(IAirConditioner airConditioner, AirConditionerSpeechRecognition speechRecognition, SpeechSynthesizer speechSynthesizer, ILogger <IAirConditioner> logger)
        {
            this.logger            = logger;
            this.airConditioner    = airConditioner;
            this.speechSynthesizer = speechSynthesizer;
            this.speechRecognizer  = speechRecognition;

            // Set up the event handler, which will redirect the commands to the appropriate code.
            speechRecognition.SpeechRecognitionEngine.SpeechRecognized += this.Recognizer_SpeechRecognized;

            this.PowerOn();
        }
        public string TestAirConditioner(string manufacturer, string model)
        {
            IAirConditioner airConditioner = database.GetAirConditioner(manufacturer, model);

            if (airConditioner == null)
            {
                throw new NonExistantEntryException();
            }
            Mark mark = (Mark)airConditioner.Test();

            database.AddReport(new Report(airConditioner.Manufacturer, airConditioner.Model, mark));
            return(string.Format(Constants.TEST, model, manufacturer));
        }
Пример #13
0
        public void DoWork(List <IAppliance> appliances)
        {
            appliances.ForEach(a =>
            {
                if (a.GetType().Name.Equals("AirConditioner"))
                {
                    IAirConditioner aa = (IAirConditioner)a;
                    aa.On();
                    aa.ChangeStrongAirvolume();
                }

                if (a.GetType().Name.Equals("Television") || a.GetType().Name.Equals("Sound"))
                {
                    a.On();
                }
            });
        }
Пример #14
0
        public void TestAirConditioner(string manufacturer, string model)
        {
            try
            {
                IAirConditioner airConditioner = this.data.GetAirConditioner(manufacturer, model);

                bool isPassed = airConditioner.Test();

                if (isPassed)
                {
                    airConditioner.Mark = "Passed";
                }

                IReport report = new Report(
                    airConditioner.Manufacturer,
                    airConditioner.Model,
                    airConditioner.Mark);

                foreach (var rep in data.Reports)
                {
                    if (rep.Manufacturer == airConditioner.Manufacturer &&
                        rep.Model == airConditioner.Model)
                    {
                        throw new DuplicateEntryException("An entry for the given model already exists.");
                    }
                }

                data.AddReport(report);
                writer.WriteLine(
                    $"Air conditioner model {airConditioner.Model}" +
                    $" from {airConditioner.Manufacturer} tested successfully");
            }
            catch (DuplicateEntryException e)
            {
                writer.WriteLine(e.Message);
            }
            catch (NullReferenceException)
            {
                writer.WriteLine("The specified entry does not exist.");
            }
        }
Пример #15
0
        public void DoWork(List <IAppliance> appliances)
        {
            appliances.ForEach(a =>
            {
                if (a.GetType().Name.Equals("AirConditioner"))
                {
                    IAirConditioner aac = (IAirConditioner)a;
                    aac.On();
                    aac.ChangeWeakAirvolume();
                }

                if (a.GetType().Name.Equals("AirPurifier"))
                {
                    IAirPurifier aap = (IAirPurifier)a;
                    aap.On();
                    aap.ChangeWeakPurifier();
                }

                if (a.GetType().Name.Equals("Dehumidifier"))
                {
                    IDehumidifier ad = (IDehumidifier)a;
                    ad.On();
                    ad.ChangeWeakDehumidifier();
                }

                if (a.GetType().Name.Equals("Sound"))
                {
                    ISound @as = (ISound)a;
                    @as.On();
                    @as.ChangeCDNumber("jojo4-op4");
                }

                if (a.GetType().Name.Equals("Television"))
                {
                    ITelevision atv = (ITelevision)a;
                    atv.On();
                    atv.ChangeTVNumber(100);
                }
            });
        }
 public void RemoveAirConditioner(IAirConditioner airConditioner)
 {
     AirConditioners.Remove(airConditioner);
 }
 public ControlPanel(IAirConditioner airConditioner, ICDPlayer cdPlayer)
 {
     this.airConditioner = airConditioner;
     this.cdPlayer       = cdPlayer;
 }
Пример #18
0
 public void RemoveAirConditioner(IAirConditioner airConditioner)
 {
     AirConditioners.Remove(airConditioner);
 }
        /// <summary>
        /// A method that finds an Air Conditioner in the database from a given manufacturer and model.
        /// </summary>
        /// <param name="manufacturer">The Manufacturer of the searched air conditioner.</param>
        /// <param name="model">The model of the searched air conditioner.</param>
        /// <returns>If the air conditioner exists in the database returns it's string represention, othrerwise it throws an appropriate exception.</returns>
        public string FindAirConditioner(string manufacturer, string model)
        {
            IAirConditioner airConditioner = this.Database.AirConditioners.GetItem(manufacturer, model);

            return(airConditioner.ToString());
        }