Esempio n. 1
0
        public static void SignIn()
        {
            string PassInput;
            bool   UserAccountCheck;
            bool   PasswordComparisonCheck;
            string space = new string(' ', 1);

            Console.WriteLine(space);
            Console.WriteLine("Login");
            Console.WriteLine("---------------------------");

            do
            {
                Console.WriteLine(space);
                Console.WriteLine("Please enter your username");
                userName = Console.ReadLine();
                string userDir = userName + @"\Username.txt";

                string UserCheck = FileOps.GetUserDir(userDir);
                UserCheck.Trim();

                if (UserCheck == "False")
                {
                    UserCheck.ToLower();
                    UserAccountCheck = Convert.ToBoolean(UserCheck);
                }
                else
                {
                    UserAccountCheck = StringCheck(userName, UserCheck);
                }
            } while (UserAccountCheck == false);

            do
            {
                Console.WriteLine(space);
                Console.WriteLine("Please enter your password");
                PassInput = Console.ReadLine();
                string passDir = userName + @"\Password.txt";

                string passRead = FileOps.GetUserDir(passDir);
                passRead.Trim();

                PasswordComparisonCheck = StringCheck(PassInput, passRead);
            } while (PasswordComparisonCheck == false);

            Console.WriteLine(space);
            Console.WriteLine("Login successful, press any key to continue");

            Console.ReadKey();

            Console.Clear();

            Difficulty.Choice();
        }
Esempio n. 2
0
        public static void DisplayUserScore(int score, int total, string subject, string difficulty)
        {
            Console.Clear();

            decimal percentage = GetPercentage(score, total);

            Console.WriteLine("You scored {0}/{1} with a percentage of {2}%", score, total, percentage);
            Console.WriteLine("Log exported");
            string userName = Login.userName;

            if (!Directory.Exists(FileOps.GetCustomUserFolder(FileOps.GetRoot()) + userName + @"\Scores"))
            {
                Directory.CreateDirectory(FileOps.GetCustomUserFolder(FileOps.GetRoot()) + userName + @"\Scores");
                File.Create(FileOps.GetCustomUserFolder(FileOps.GetRoot()) + userName + @"\Scores" + @"\UserScores.txt").Close();
            }

            string[] arrayForGrade = new string[5] {
                "1c", "2c", "3c", "4c", "5c"
            };

            string dir = FileOps.GetCustomUserFolder(FileOps.GetRoot()) + userName + @"\Scores" + @"\UserScores.txt";

            int scoreForGrade = score - 1;

            string forAppend = "You scored " + score + " with a percentage of " + percentage + "% and a grade of " + arrayForGrade[scoreForGrade] + ". Subject: " + subject + " | Difficulty: " + difficulty + " at " + DateTime.Now; //F*****g horrible why does it force me to do this TRY TO FIND A WAY TO NOT DO THIS

            File.AppendAllText(dir, forAppend + Environment.NewLine);

            bool forEndLoop = false;

            do
            {
                forEndLoop = false;
                Console.WriteLine("");
                Console.WriteLine("What would you like to do next?");
                Console.WriteLine("A. Play the quiz again");
                Console.WriteLine("B. Choose a different quiz");
                Console.WriteLine("C. Log-out");
                Console.WriteLine("D. Quit");
                string endOfQuizChoice = Console.ReadLine().ToUpper();

                switch (endOfQuizChoice)
                {
                case "A":
                    Console.Clear();
                    Questions.QuestionsMain();
                    break;

                case "B":
                    Console.Clear();
                    Difficulty.Choice();
                    break;

                case "C":
                    Console.Clear();
                    Login.SignIn();
                    break;

                case "D":
                    Environment.Exit(1);
                    break;

                default:
                    Console.Clear();
                    Console.WriteLine("You did not enter a correct response");
                    forEndLoop = true;
                    break;
                }
            } while (forEndLoop == true);

            Console.ReadKey();
        }