Пример #1
0
        //This functions gets the full list of trivia questions from the Trivia.txt document
        static List <Trivia> GetTriviaList()
        {
            //Get Contents from the file.  Remove the special char "\r".  Split on each line.  Convert to a list.
            //List<string> contents = File.ReadAllText("~/trivia.txt").Replace("\r", "").Split('\n').ToList();
            var    assembly     = Assembly.GetExecutingAssembly();
            var    resourceName = "TriviaGame.trivia.txt";
            string result;

            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                using (StreamReader reader = new StreamReader(stream))
                {
                    result = reader.ReadToEnd();
                }

            List <string> contents = result.Replace("\r", "").Split('\n').ToList();
            //Each item in list "contents" is now one line of the Trivia.txt document.

            //make a new list to return all trivia questions
            List <Trivia> returnList = new List <Trivia>();

            // TODO: go through each line in contents of the trivia file and make a trivia object.
            //       add it to our return list.
            // Example: Trivia newTrivia = new Trivia("what is my name?*question");
            foreach (string question in contents)
            {
                Trivia triviaObject = new Trivia(question);
                //add the new object to returnList
                returnList.Add(triviaObject);
            }
            //Return the full list of trivia questions
            return(returnList);
        }
Пример #2
0
        static void QuotesQuestion()
        {
            var rando = new Random();

            int line = rando.Next(0, FilmQuotes.Count);

            Trivia questionPicked = FilmQuotes[line];

            QuestionCheck11(questionPicked);
        }
Пример #3
0
        static void ZodiacQuestion()
        {
            var rando = new Random();

            int line = rando.Next(0, Zodiac.Count);

            Trivia questionPicked = Zodiac[line];

            QuestionCheck10(questionPicked);
        }
Пример #4
0
        static void SingersQuestion()
        {
            var rando = new Random();

            int line = rando.Next(0, LeadSingers.Count);

            Trivia questionPicked = LeadSingers[line];

            QuestionCheck13(questionPicked);
        }
Пример #5
0
        static void EightysFilmsQuestion()
        {
            var rando = new Random();

            int line = rando.Next(0, EightysFilms.Count);

            Trivia questionPicked = EightysFilms[line];

            QuestionCheck8(questionPicked);
        }
Пример #6
0
        static void SportsQuestion()
        {
            var rando = new Random();

            int line = rando.Next(0, Sports.Count);

            Trivia questionPicked = Sports[line];

            QuestionCheck7(questionPicked);
        }
Пример #7
0
        static void SciQuestion()
        {
            var rando = new Random();

            int line = rando.Next(0, Science.Count);

            Trivia questionPicked = Science[line];

            QuestionCheck6(questionPicked);
        }
Пример #8
0
        static void EnmtQuestion()
        {
            var rando = new Random();

            int line = rando.Next(0, Entertainment.Count);

            Trivia questionPicked = Entertainment[line];

            QuestionCheck5(questionPicked);
        }
Пример #9
0
        static void GeoQuestion()
        {
            var rando = new Random();

            int line = rando.Next(0, Geography.Count);

            Trivia questionPicked = Geography[line];

            QuestionCheck3(questionPicked);
        }
Пример #10
0
        static void HistQuestion()
        {
            var rando = new Random();

            int line = rando.Next(0, History.Count);

            Trivia questionPicked = History[line];

            QuestionCheck2(questionPicked);
        }
Пример #11
0
        static void RandomQuestion()
        {
            var rando = new Random();

            int line = rando.Next(0, NameTheArtist.Count);

            Trivia questionPicked = NameTheArtist[line];

            QuestionCheck14(questionPicked);
        }
Пример #12
0
        static void GamesQuestion()
        {
            var rando = new Random();

            int line = rando.Next(0, VideoGames.Count);

            Trivia questionPicked = VideoGames[line];

            QuestionCheck12(questionPicked);
        }
Пример #13
0
        static void CapsQuestion()
        {
            var rando = new Random();

            int line = rando.Next(0, Capitals.Count);

            Trivia questionPicked = Capitals[line];

            QuestionCheck9(questionPicked);
        }
Пример #14
0
        static void Main(string[] args)
        {
            //The logic for your trivia game happens here
            QuestionList = GetTriviaList();
            List<Trivia> AllQuestions = GetTriviaList();
            Console.WriteLine("Hello, welcome to SeedPaths Trivia Game!  What is your name?");
            string input = Console.ReadLine();
            Console.WriteLine("Hello, " + input + " lets play!");
            Console.WriteLine("You will be asked random trivia questions and depending on your answer, you will be told if you are right or wrong.");

            int turnsLeft = 5;
            int questionsRight = 0;

            while (questionsRight <= 5000 || turnsLeft >= 0)
            {
                int score = 0;
                Random newTrivia = new Random();
                int number = newTrivia.Next(0, QuestionList.Count());
                Trivia output = QuestionList[number];
                Console.WriteLine(newTrivia.Tell());
                Console.WriteLine("Enter your answer");
                string answer = Console.ReadLine().ToLower();
                if (answer == newTrivia.Tell())
                {

                    Console.WriteLine("You have answered: " + score + "correctly, and you still have: " + turnsLeft + " turns left.");
                    Console.WriteLine("Correct!");
                    score++;
                }
                else
                {

                    Console.WriteLine("You have answered: " + score + "correctly, and you still have: " + turnsLeft + " turns left.");

                    Console.WriteLine("The correct answer is: " + newTrivia.Tell());
                    turnsLeft--;
                    if (turnsLeft == 4)
                    {
                        Console.WriteLine("You have only used one turn. you still have 4 left!");
                    }
                    else if (turnsLeft == 3)
                    {
                        Console.WriteLine("You still have three turns left!");
                    }
                    else if (turnsLeft == 2)
                    {
                        Console.WriteLine("Two turns left!");
                    }
                    else if (turnsLeft == 1)
                    {
                        Console.WriteLine("Only one turn left!");
                    }
                }
            }
        }
Пример #15
0
        static void CompChooseQuestion()
        {
            //choose random question
            Random randomQuestion = new Random();
            int    random         = randomQuestion.Next(1, contents.Count);

            questionTemp = contents[random];

            //print random question
            Console.WriteLine("Here is your question: ");
            Console.WriteLine();
            Console.WriteLine(questionTemp.Question + "?");
        }
Пример #16
0
        static void QuestionCheck14(Trivia question)
        {
            foreach (Trivia item in QuestionsAsked)
            {
                if (question.Question == item.Question)
                {
                    RandomQuestion();
                    break;
                }
            }
            QuestionsAsked.Add(question);

            GameTime(question.Question);
        }
Пример #17
0
        static void QuestionCheck8(Trivia question)
        {
            foreach (Trivia item in QuestionsAsked)
            {
                if (question.Question == item.Question)
                {
                    EightysFilmsQuestion();
                    break;
                }
            }
            QuestionsAsked.Add(question);

            GameTime(question.Question);
        }
Пример #18
0
 public FallingThings(int maxThings, double framerate, int intraFrames)
 {
     this.maxThings   = maxThings;
     this.intraFrames = intraFrames;
     targetFrameRate  = framerate * intraFrames;
     SetGravity(gravityFactor);
     sceneRect.X     = sceneRect.Y = 0;
     sceneRect.Width = sceneRect.Height = 100;
     shapeSize       = sceneRect.Height * baseShapeSize / 1000.0;
     expandingRate   = Math.Exp(Math.Log(6.0) / (targetFrameRate * DissolveTime));
     randomYPosition = new Random();
     trivia          = new Trivia();
     questions       = trivia.Questions.ToList();
     game            = new Game {
         GamDateTime = DateTime.Now
     };
     difficultyOptions = trivia.Answers.Where(diff => diff.AnsQueID == 3).ToList();
 }
Пример #19
0
        //This function gets the full list of trivia questions from the Trivia.txt document
        static List<Trivia> GetTriviaList()
        {
            //Get Contents from the file.  Remove the special char "\r".  Split on each line.  Convert to a list.
            List<string> contents = File.ReadAllText("trivia.txt").Replace("\r", "").Split('\n').ToList();

            //Each item in list "contents" is now one line of the Trivia.txt document.

            //make a new list to return all trivia questions
            List<Trivia> returnList = new List<Trivia>();
            // TODO: go through each line in contents of the trivia file and make a trivia object.
            //       add it to our return list.
            foreach (string question in contents)
            {
                Trivia a = new Trivia(question);
                returnList.Add(a);
            }

            //Return the full list of trivia questions
            return returnList;
        }
Пример #20
0
        //This functions gets the full list of trivia questions from the Trivia.txt document
        static List<Trivia> GetTriviaList()
        {
            //Get Contents from the file.  Remove the special char "\r".  Split on each line.  Convert to a list.
            List<string> contents = File.ReadAllText("trivia.txt").Replace("\r", "").Split('\n').ToList();

            //Each item in list "contents" is now one line of the Trivia.txt document.

            //make a new list to return all trivia questions
            List<Trivia> returnList = new List<Trivia>();
            // TODO: go through each line in contents of the trivia file and make a trivia object.
            //       add it to our return list.
            // Example: Trivia newTrivia = new Trivia("what is my name?*question");
            //Go through every string (QandA) in contents
            foreach (string s in contents)
            {
                //Declare newTrivia for every string in contents, separated into question and answer
                Trivia newTrivia = new Trivia(s);
                returnList.Add(newTrivia);
            }
            //Return the full list of trivia questions
            return returnList;
        }
Пример #21
0
        //This functions gets the full list of trivia questions from the Trivia.txt document
        static List <Trivia> GetTriviaList()
        {
            //Get Contents from the file.  Remove the special char "\r".  Split on each line.  Convert to a list.
            List <string> contents = File.ReadAllText("trivia.txt").Replace("\r", "").Split('\n').ToList();

            //Each item in list "contents" is now one line of the Trivia.txt document.

            //make a new list to return all trivia questions

            List <Trivia> returnList = new List <Trivia>();

            // TODO: go through each line in contents of the trivia file and make a trivia object.
            //       add it to our return list.
            // Example: Trivia newTrivia = new Trivia("what is my name?*question");
            //Return the full list of trivia questions
            foreach (var item in contents)
            {
                Trivia newTrivia = new Trivia(item);
                returnList.Add(newTrivia);
            }

            return(returnList);
        }
Пример #22
0
        //This functions gets the full list of trivia questions from the Trivia.txt document
        static List<Trivia> GetTriviaList()
        {
            //Get Contents from the file.  Remove the special char "\r".  Split on each line.  Convert to a list.
            List<string> contents = File.ReadAllText("trivia.txt").Replace("\r", "").Split('\n').ToList();

            //Each item in list "contents" is now one line of the Trivia.txt document.
            
            //make a new list to return all trivia questions
            List<Trivia> returnList = new List<Trivia>();
            // TODO: go through each line in contents of the trivia file and make a trivia object.
            //       add it to our return list.
            // Example: Trivia newTrivia = new Trivia("what is my name?*question");
           
            string line;

            // Read the file and display it line by line.
            try
            {
            StreamReader file =
               new StreamReader("trivia.txt");

            while ((line = file.ReadLine()) != null)
                {
                    Trivia questions = new Trivia(line);
                    returnList.Add(questions);
                }

                file.Close();
            }
            catch (FileNotFoundException exception)
            {
                Console.WriteLine(exception);
            }

            //Return the full list of trivia questions
            return returnList;
        }