Ejemplo n.º 1
0
        public bool ValidatePattern(string rep)
        {
            Dictionary <string, string> dictionary = new LettersPattern().ProvideDictionary();
            List <string> repPatterns = rep.Split('1').ToList();

            repPatterns.Remove(repPatterns.Last());
            int patternCount = 0;

            foreach (var pattern in repPatterns)
            {
                if (dictionary.ContainsValue(pattern))
                {
                    patternCount++;
                }
            }
            return(patternCount == repPatterns.Count);
        }
Ejemplo n.º 2
0
        public string ConvertRep(string rep)
        {
            string convertedString = "";

            if (validator.ValidateRep(rep) != null && rep.Length > 0)
            {
                Dictionary <string, string> dictionary = new LettersPattern().ProvideDictionary();

                foreach (var pattern in SplitStringRepresentation(rep))
                {
                    convertedString += dictionary.FirstOrDefault(d => d.Value == pattern).Key;
                }
            }
            else if (rep.Length == 0)
            {
                convertedString = "I have nothing to convert (but that's okay!)";
            }
            else
            {
                convertedString = "You've entered an invalid string!";
            }
            return(convertedString);
        }