コード例 #1
0
ファイル: Service.cs プロジェクト: csk157/exam-system-csharp
        public void Remove(Model.Model m)
        {
            m.Delete();
            switch (m.Table)
            {
            case "Educations":
                Educations.Remove((Education)m);
                break;

            case "Students":
                Students.Remove((Student)m);
                break;

            case "Exams":
                Exams.Remove((Exam)m);
                break;

            case "Attempts":
                Attempts.Remove((Attempt)m);
                break;
            }

            dao.UpdateData();
            m.AfterDelete();
        }
コード例 #2
0
ファイル: Game.cs プロジェクト: Limon105/BullsAndCows
        public void AnalysisReceivedData(ref int attemptNumber)
        {
            bool winnerNumbersCowIsAlreadyFound = Convert.ToBoolean(WinnerNumbersCows.Count);

            for (int k = 0; k < Attempts.Count; k++)
            {
                Attempt attempt = Attempts[k];
                if (attempt.CountBulls + attempt.CountCows == 4)
                {
                    if (attempt.CountBulls == 3 && attempt.CountCows == 1)
                    {
                        Console.WriteLine($"Вы запутались в решении поскольку, невозможно чтобы было {attempt.CountBulls} быка и {attempt.CountCows}");
                        Attempts.Remove(attempt);
                        attemptNumber--;
                    }
                    else
                    {
                        if (attempt.CountBulls == 4)
                        {
                            Console.WriteLine($"Решение найдено - > {attempt.Number}");
                            break;
                        }
                        else
                        {
                            if (!winnerNumbersCowIsAlreadyFound)
                            {
                                Console.WriteLine($"Найдены все цифры которые используются в решении -> {attempt.Number}");
                                for (int i = 0; i < attempt.Number.Length; i++)
                                {
                                    WinnerNumbersCows.Add(attempt.Number[i]);
                                }
                                winnerNumbersCowIsAlreadyFound = true;
                                Delete();
                            }
                            FindBullsForWin();
                            break;
                        }
                    }
                }
                else
                {
                    if (attempt.CountBulls + attempt.CountCows == 0)
                    {
                        Console.WriteLine($"Найдено числа которые не используются в решении -> {attempt.Number}");
                        Delete(attempt);
                        Attempts.Remove(attempt);
                        attemptNumber--;
                        break;
                    }
                }
            }
            if (Attempts.Count != 0)
            {
                FindCowsForWin(Attempts[Attempts.Count - 1]);
            }
        }