Advertisement
allerost

Updated Question Game!

Sep 9th, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.82 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Threading;
  7.  
  8. namespace Frågesprotspel
  9. {
  10.  
  11.     //namnet på programmet.
  12.     class Program
  13.     {
  14.  
  15.         //start på programmet
  16.         static void Main(string[] args)
  17.         {
  18.             //String säger vad rätt svar är.
  19.             string answer1 = "lbs";
  20.             string answer2 = "200";
  21.             string answer3 = "t";
  22.             string answer4 = "a";
  23.             string answer5 = "45";
  24.             //userInput sparar datan som personer skriver in.
  25.             string userInput1;
  26.             string userInput2;
  27.             string userInput3;
  28.             string userInput4;
  29.             string userInput5;
  30.             string userInput6;
  31.             string userInput7;
  32.             int correctAnswer = 0;
  33.             int sec = 1500;
  34.  
  35.             //Alla frågot ligger i dessa regions under.
  36.             #region
  37.             Console.ForegroundColor = ConsoleColor.Green;
  38.             Console.WriteLine("                                                                       Score : {0}", correctAnswer);
  39.             //Säger till vad du ska göra
  40.             Console.ForegroundColor = ConsoleColor.Yellow;
  41.             Console.Write("            Answer the following questions. OBS: ALL LOWER CASE!");
  42.             Console.ForegroundColor = ConsoleColor.White;
  43.             Console.WriteLine("");
  44.  
  45.  
  46.             //första frågan
  47.             Console.WriteLine("What is the name of the school this quiz was made in?");
  48.             //kollar vad du skriver om sparar det
  49.             userInput1 = Console.ReadLine().ToLower();
  50.             // if = om du skriver rätt så händer det inom den
  51.             if (userInput1 == answer1)
  52.             {
  53.                 Console.ForegroundColor = ConsoleColor.Green;
  54.                 Console.WriteLine("Correct! You have gained one point!");
  55.                 //correctAnswer ger dig ett poäng som sparas i en int variabel.
  56.                 correctAnswer++;
  57.                 Thread.Sleep(sec);
  58.                 Console.Clear();
  59.  
  60.             }
  61.             //Else = vad som händer om du svarar fel
  62.             else
  63.             {
  64.                 Console.ForegroundColor = ConsoleColor.Red;
  65.                 Console.WriteLine("False! The correct answer is {0}!", answer1);
  66.                 Thread.Sleep(sec);
  67.                 Console.Clear();
  68.  
  69.             }
  70.             #endregion
  71.             #region
  72.  
  73.             Console.ForegroundColor = ConsoleColor.White;
  74.             // andra frågan
  75.             Console.WriteLine("What do you get if you add 100 + 100?");
  76.             Console.ForegroundColor = ConsoleColor.Green;
  77.             Console.WriteLine("                                                                       Score : {0}", correctAnswer);
  78.             Console.ForegroundColor = ConsoleColor.White;
  79.             userInput2 = Console.ReadLine().ToLower();
  80.             if (userInput2 == answer2)
  81.             {
  82.                 Console.ForegroundColor = ConsoleColor.Green;
  83.                 Console.WriteLine("Correct! You have gained one point!");
  84.                 //correctanswer ger dig ett poäng och sparar det i en int variabel.
  85.                 correctAnswer++;
  86.                 Console.ForegroundColor = ConsoleColor.White;
  87.                 //Thread stoppar programmet för 1.5 sec för att kunna läsa texten.
  88.                 Thread.Sleep(sec);
  89.                 //console.clear tar bort texten innan nästa fråga börjar.
  90.                 Console.Clear();
  91.             }
  92.             else
  93.             {
  94.                 Console.ForegroundColor = ConsoleColor.Red;
  95.                 Console.WriteLine("False! The correct answer is {0}!", answer2);
  96.                 Thread.Sleep(sec);
  97.                 Console.Clear();
  98.             }
  99.             #endregion
  100.             #region
  101.             Console.ForegroundColor = ConsoleColor.White;
  102.             Console.WriteLine(" What is the 20th letter in the alphabet?");
  103.             Console.ForegroundColor = ConsoleColor.Green;
  104.             Console.WriteLine("                                                                       Score : {0}", correctAnswer);
  105.             Console.ForegroundColor = ConsoleColor.White;
  106.             userInput3 = Console.ReadLine().ToLower();
  107.             if (userInput3 == answer3)
  108.             {
  109.                 Console.ForegroundColor = ConsoleColor.Green;
  110.                 Console.WriteLine("Correct! You have gained one point!");
  111.                 correctAnswer++;
  112.                 Thread.Sleep(sec);
  113.                 Console.Clear();
  114.             }
  115.             else
  116.             {
  117.                 Console.ForegroundColor = ConsoleColor.Red;
  118.                 Console.WriteLine(" False! The correct answer is {0}", answer3);
  119.                 Thread.Sleep(sec);
  120.                 Console.Clear();
  121.  
  122.             }
  123.             #endregion
  124.             #region
  125.  
  126.             Console.ForegroundColor = ConsoleColor.White;
  127.             Console.WriteLine("What is the first letter in my name?");
  128.             Console.ForegroundColor = ConsoleColor.Green;
  129.             Console.WriteLine("                                                                       Score : {0}", correctAnswer);
  130.             Console.ForegroundColor = ConsoleColor.White;
  131.             userInput4 = Console.ReadLine().ToLower();
  132.             if (userInput4 == answer4)
  133.             {
  134.                 Console.ForegroundColor = ConsoleColor.Green;
  135.                 Console.WriteLine("Correct! You got a point!");
  136.                 correctAnswer++;
  137.                 Thread.Sleep(sec);
  138.                 Console.Clear();
  139.             }
  140.             else
  141.             {
  142.                 Console.ForegroundColor = ConsoleColor.Red;
  143.                 Console.WriteLine("False! The correct answer is {0}", answer4);
  144.                 Thread.Sleep(sec);
  145.                 Console.Clear();
  146.             }
  147.             #endregion
  148.             #region
  149.             Console.ForegroundColor = ConsoleColor.White;
  150.             Console.WriteLine("What is the answer to this? (10x2)2+5= ");
  151.             Console.ForegroundColor = ConsoleColor.Green;
  152.             Console.WriteLine("                                                                       Score : {0}", correctAnswer);
  153.             Console.ForegroundColor = ConsoleColor.White;
  154.             userInput5 = Console.ReadLine().ToLower();
  155.             if (userInput5 == answer5)
  156.             {
  157.                 Console.ForegroundColor = ConsoleColor.Green;
  158.                 Console.WriteLine("Correct! You got a point!");
  159.                 correctAnswer++;
  160.                 Thread.Sleep(sec);
  161.                 Console.Clear();
  162.             }
  163.             else
  164.             {
  165.                 Console.ForegroundColor = ConsoleColor.Red;
  166.                 Console.WriteLine("False! The correct answer is {0}", answer5);
  167.                 Thread.Sleep(sec);
  168.                 Console.Clear();
  169.             }
  170.             #endregion
  171.  
  172.             Console.WriteLine();
  173.             //Skriver ut hur många poäng du fick totalt.
  174.             Console.ForegroundColor = ConsoleColor.Blue;
  175.             Console.WriteLine("                               Amout of point : {0} ", correctAnswer);
  176.             //console.Readkey används hör att hålla CMD öppen.
  177.             Console.WriteLine("-------------------------------------------------------------------------------");
  178.             Thread.Sleep(sec);
  179.             Console.ForegroundColor = ConsoleColor.White;
  180.             Console.WriteLine("Would you like to make a bet? With all your points as the bet?.");
  181.             Console.WriteLine("If you win you gain 10, But if you were to lose, You lose it ALL.");
  182.             Console.WriteLine("Does it sound like a fair deal? ");
  183.             Console.WriteLine("Reply with yes or no depending on what you choose.");
  184.             userInput6 = Console.ReadLine().ToLower();
  185.             if (userInput6 == "yes")
  186.             {
  187.                 Console.WriteLine("Well here we go then! Let us do this.");
  188.                 Thread.Sleep(sec);
  189.                 Console.WriteLine("");
  190.                 Console.WriteLine("The question is simple. Who taught me how to do this?");
  191.                 Console.WriteLine("And with this I mean, Programming, Who taught me?");
  192.                 userInput7 = Console.ReadLine().ToLower();
  193.                 if (userInput7 == "josef")
  194.                 {
  195.                     Console.WriteLine("");
  196.                     Console.WriteLine("You are a smart man, You were right and won the bet.");
  197.                     Console.ForegroundColor = ConsoleColor.Green;
  198.                     Console.WriteLine("You will be rewarded 10 points, Congratulations. Enjoy the victory!");
  199.                     Thread.Sleep(sec);
  200.                     Console.WriteLine("Your total amout of points are : {0}", correctAnswer + 10);
  201.                 }
  202.                 else
  203.                 {
  204.                     Console.WriteLine("");
  205.                     Console.WriteLine("Ouch! That was the wrong answer. I am sorry you have lost.");
  206.                     Console.WriteLine("This means you are going to lose all of your points. Well Fought.");
  207.                     Thread.Sleep(sec);
  208.                     Console.ForegroundColor = ConsoleColor.Red;
  209.                     Console.WriteLine("All of your points have now been moved. GAME OVER.");
  210.                     Console.WriteLine("Your total amout of points are: {0}", correctAnswer - correctAnswer);
  211.                 }
  212.             }
  213.             else
  214.             {
  215.                 Console.WriteLine("Well maybe it was for the best, maybe you are not smart enough.");
  216.                 Console.WriteLine("Anyways it was fun playing you. You fought well.");
  217.                 Console.WriteLine("");
  218.                 Console.WriteLine("You total amout of points are : {0}", correctAnswer);
  219.             }
  220.  
  221.             Console.ReadKey();
  222.         }
  223.     }
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement