Пример #1
0
        void ShowWord(int number)
        {
            var context = new WordsEntities1();
            var word    = context.Table.First(x => x.Id == number);

            Console.WriteLine("{0}", word.translation);
        }
Пример #2
0
        private bool CheckAnswear(string answear, int number)
        {
            var context = new WordsEntities1();
            var word    = context.Table.First(x => x.Id == number);

            Console.WriteLine("\nPoprawna odpowiedź to:\n {0} {1} {2}\n", word.GermanWord, word.Preposition, word.wordCase);
            var ans = answear.Split(' ');

            string german, prepo, wordCase;

            if (ans.Count() == 4)
            {
                german   = ans[0] + ' ' + ans[1]; //if first part is two words concat
                prepo    = ans[2];
                wordCase = ans[3];
            }
            else if (ans.Count() == 3)
            {
                german   = ans[0];
                prepo    = ans[1];
                wordCase = ans[2];
            }
            else
            {
                return(false);  //wrong answear if to few words
            }
            if (german.Equals(word.GermanWord) && prepo.Equals(word.Preposition) && wordCase.ToUpper().Equals(word.wordCase))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        private bool Add(string germangermanWord, string prep, string wordCase, string translation)
        {
            var context = new WordsEntities1();
            int id      = context.Table.Count() + 1;
            var newWord = new Table();

            newWord.Id          = id;
            newWord.GermanWord  = germangermanWord;
            newWord.Preposition = prep;
            newWord.wordCase    = wordCase;
            newWord.translation = translation;
            context.Table.Add(newWord);
            var result = context.SaveChanges();

            Console.WriteLine(result.ToString());
            Console.ReadLine();
            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        private void Edit(int noWord)
        {
            Console.Clear();
            var context   = new WordsEntities1();
            int wordCount = context.Table.Count();

            if (noWord > wordCount)
            {
                Console.WriteLine("Nie ma w bazie słowa o podanym indeksie!");
                Console.ReadLine();
                return;
            }
            Console.WriteLine("Co chcesz edytować?\n" +
                              "1. Słowo niemieckie\n" +
                              "2. Przyimek\n" +
                              "3. Przypadek\n" +
                              "4. Tłumaczenie");
            char choice = Convert.ToChar(Console.Read());

            Console.ReadLine();
            var    oldWord = context.Table.First(x => x.Id == noWord);
            string newWord;

            switch (choice)
            {
            case '1':
                Console.WriteLine("Poprzednie słowo było {0}\n Podaj nowe brzmienie:", oldWord.GermanWord);
                newWord            = Console.ReadLine();
                oldWord.GermanWord = newWord;
                int num = context.SaveChanges();
                break;

            case '2':
                Console.WriteLine("Poprzednie słowo było {0}\n Podaj nowe brzmienie:", oldWord.Preposition);
                newWord             = Console.ReadLine();
                oldWord.Preposition = newWord;
                context.SaveChanges();
                break;

            case '3':
                Console.WriteLine("Poprzednie słowo było {0}\n Podaj nowe brzmienie:", oldWord.wordCase);
                newWord          = Console.ReadLine();
                oldWord.wordCase = newWord;
                context.SaveChanges();
                break;

            case '4':
                Console.WriteLine("Poprzednie słowo było {0}\n Podaj nowe brzmienie:", oldWord.translation);
                newWord             = Console.ReadLine();
                oldWord.translation = newWord;
                context.SaveChanges();
                break;

            default:
                Console.WriteLine("Nie ma takiej opcji");
                Console.ReadLine();
                break;
            }
        }
Пример #5
0
        void RandomizeWords()
        {
            Random rand    = new Random();
            var    context = new WordsEntities1();
            int    noWords = context.Table.Count();

            randomWords = new int[10];

            for (int i = 0; i < 10; i++)
            {
                randomWords[i] = rand.Next(noWords) + 1;
            }
        }
Пример #6
0
        void Show()
        {
            var context = new WordsEntities1();
            int pages   = context.Table.Count() / 10 + 1;

            for (int i = 0; i < pages; i++)
            {
                Console.Clear();
                var word = context.Table.Where(x => x.Id <= 10 * (i + 1) && x.Id > 10 * i);
                foreach (var item in word)
                {
                    Console.WriteLine("{0}. {1} {2} {3} - {4}", item.Id, item.GermanWord, item.Preposition, item.wordCase, item.translation);
                }
                Console.WriteLine("Strona {0} z {1}, Enter aby kontynuować ...", i + 1, pages);
                Console.ReadLine();
            }
        }