Beispiel #1
0
        internal DressCommand CreateDressCommand(string commandListString)
        {
            DressCommand dressCommand = null;

            WEATHER_ENUM        weather     = getWeather(commandListString);
            List <COMMAND_ENUM> commandList = createCommandList(commandListString);

            if (weather == WEATHER_ENUM.HOT)
            {
                // Create hot string converter
                HotEnumToStringConverter hotEnumStringConverter = new HotEnumToStringConverter();
                // Create hot dress command
                dressCommand = new HotDressCommand(commandList, hotEnumStringConverter);
            }
            else if (weather == WEATHER_ENUM.COLD)
            {
                // Create cold string converter
                ColdEnumToStringConverter coldEnumStringConverter = new ColdEnumToStringConverter();
                // Create cold dress command
                dressCommand = new ColdDressCommand(commandList, coldEnumStringConverter);
            }
            else
            {
                // Do nothing
            }
            return(dressCommand);
        }
Beispiel #2
0
        public string Validate(string commandLineString)
        {
            string output = "";

            try
            {
                DressCommand dressCommand = CommandFactory.Instance.CreateDressCommand(commandLineString);

                if (dressCommand != null)
                {
                    output = dressCommand.Validate();
                }
                else
                {
                    // not sure what is the requirement for invalid inputs.. Make it fail for now.
                    output = "fail";
                }
            }
            catch (Exception ex)
            {
                // Got exception... let's just output it for now
                output = ex.Message;
            }

            return(output);
        }