示例#1
0
        static int Countlines(string QADir)
        {
            string root    = FileOps.GetRoot();
            string userDir = FileOps.GetCustomUserFolder(root);

            int i = File.ReadAllLines(userDir + @"\" + QADir + "Answers.txt").Count();
            int j = File.ReadAllLines(userDir + @"\" + QADir + "Questions.txt").Count();

            if (i != j)
            {
                Console.WriteLine("Warning: Amount of questions and answers does not match");
                if (i > j)
                {
                    return(i);
                }
                else if (j > i)
                {
                    return(j);
                }
            }

            return(i);
        }
示例#2
0
        static void PostFirstTimeSetupFlow()
        {
            string[] userData = new string[5];

            string        root         = FileOps.GetRoot();
            DirectoryInfo countFolders = new DirectoryInfo(FileOps.GetCustomUserFolder(root));

            int postFirstTimeSetupCheck = countFolders.EnumerateDirectories().Count();

            if (postFirstTimeSetupCheck == 1)
            {
                Console.WriteLine("No user accounts detected, press any key to continue");
                Console.ReadKey();
                userData = UserInfo();

                userData[4] = userData[0].Substring(0, 3) + userData[2];
                Console.WriteLine("Your username is {0}", userData[4]);

                FileOps.MainFW(userData.ToArray());
            }

            return;
        }
示例#3
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();
        }