Beispiel #1
0
        public Letters Subtract(Letters second)
        {
            string letters1 = characters;
            string letters2 = second.characters;
            string different_letters = "";

            while (true)
            {
                if (letters2.Length == 0) return new Letters(different_letters + letters1);
                if (letters1.Length == 0) return null;
                {
                    char letter2 = letters2[0];
                    char letter1 = letters1[0];
                    if (letter1 > letter2) return null;

                    if (letter1 < letter2)
                    {
                        letters1 = letters1.Substring(1);
                        different_letters += letter1;
                        continue;
                    }

                    //if (letter1 == letter2) throw new Exception("Error: letter1 == letter2");

                    letters1 = letters1.Substring(1);
                    letters2 = letters2.Substring(1);
                }
            }
        }
Beispiel #2
0
 private static string Subtract(string first, string sencod)
 {
     Letters letters1 = new Letters(first);
     Letters letters2 = new Letters(sencod);
     Letters different_letters = letters1.Subtract(letters2);
     if (different_letters == null) return null;
     return different_letters.ToString();
 }