コード例 #1
0
        public static void NeaFolderDataCheck()
        {
            bool   do1  = false;
            string root = FileOps.GetRoot();

            if (!Directory.Exists(@"C:\NeaFolderData"))
            {
                do
                {
                    Console.WriteLine("Is this your first time running the software? Yes or No?");
                    string firstRunAnswer = Console.ReadLine();
                    firstRunAnswer.ToLower();

                    if (firstRunAnswer == "yes")
                    {
                        Console.WriteLine("Running first time setup...");
                        FirstTimeSetup.MainFTS();
                    }
                    else if (firstRunAnswer == "no")
                    {
                        Console.Clear();
                        Console.WriteLine("Error: NeaFolderData not found");
                        ApplicationDriveChangeFix();
                    }
                    else
                    {
                        Console.Clear();
                        Console.WriteLine("Please enter yes or no");
                        Console.WriteLine(" ");
                        do1 = true;
                    }
                } while (do1 == true);
            }
        }
コード例 #2
0
        public static void MainFTS()
        {
            string root = FileOps.GetRoot();

            Console.Clear();
            Console.WriteLine("You will now setup your user data/questions location.");
            Console.WriteLine("It will be saved on your current drive that the executable is running on");

            Console.WriteLine("Please enter the name you'd like for your user data/questions folder");
            string userFolderName = Console.ReadLine();

            Console.WriteLine("");
            Console.WriteLine("Creating Directories...");
            Console.WriteLine("-------------------------");

            string[] subDirs = new string[3] {
                @"\Easy", @"\Medium", @"\Hard"
            };
            string[] dirs = new string[3] {
                @"\Computer Science", @"\History", @"\Music"
            };

            string questionDirs = (root + userFolderName + @"\Questions");

            for (int i = 0; i < 3; i++)
            {
                foreach (string subDir in subDirs)
                {
                    Directory.CreateDirectory(questionDirs + dirs[i] + subDir);
                }
            }

            string userFolderLocation = root + userFolderName;

            string permDir = @"C:\NeaFolderData";

            Directory.CreateDirectory(permDir);

            File.Create(permDir + @"\path.txt").Close();

            StreamWriter writer = new StreamWriter(permDir + @"\path.txt");

            writer.WriteLine(userFolderLocation);
            writer.Close();

            Console.WriteLine("Done. Created {0} and {1}. Press any key to continue", userFolderLocation, permDir);
            Console.ReadKey();

            Console.Clear();

            Start.Main();
        }
コード例 #3
0
        public static void NoUserFolderCatch()
        {
            string root = FileOps.GetRoot();
            string r    = FileOps.GetCustomUserFolder(root);

            if (Directory.Exists(r) == false)
            {
                Console.WriteLine("User account folder is missing, it will now be recreated");
                string        p = @"C:\NeaFolderData";
                DirectoryInfo d = new DirectoryInfo(p);
                d.Delete(true);
                Console.WriteLine("");
                Console.WriteLine("You will now run through the first time setup again, press any key to continue");
                Console.ReadKey();
                FirstTimeSetup.MainFTS();
            }
            return;
        }
コード例 #4
0
        public static void QuestionsMain()
        {
            string root = FileOps.GetRoot();

            string[] difficultyAndSubjectArray   = Difficulty.usersChoice;
            string   questionAnwserDifficultyDir = @"Questions\" + difficultyAndSubjectArray[0] + @"\" + difficultyAndSubjectArray[1] + @"\";
            int      score           = 0;
            int      totalForPercent = 0;
            int      line            = 1;
            int      numberOfLines   = Countlines(questionAnwserDifficultyDir);

            Console.WriteLine("Press enter to start your quiz");
            Console.ReadKey();
            Console.Clear();

            for (int i = 0; i < numberOfLines; i++)
            {
                if (i > 0)
                {
                    Console.WriteLine(" ");
                }

                string[] questionAnswer = QAGet(root, questionAnwserDifficultyDir, line);

                Console.WriteLine(questionAnswer[0]);
                string userRespone = Console.ReadLine();

                if (userRespone == questionAnswer[1])
                {
                    Console.WriteLine("Correct");
                    score++;
                    totalForPercent++;
                    line++;
                }
                else if (userRespone != questionAnswer[1])
                {
                    Console.WriteLine("False");
                    totalForPercent++;
                    line++;
                }
            }

            AfterQuestions.DisplayUserScore(score, totalForPercent, difficultyAndSubjectArray[0], difficultyAndSubjectArray[1]);
        }
コード例 #5
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);
        }
コード例 #6
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;
        }
コード例 #7
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();
        }