jeudi 1 août 2019

Why do it terminated if i enter a different name besides "dennis"?

Hello i am still young(i started learning less two weeks) and i trying to do quiz game for my friends.

I tried to change the places for some if or changes the places or add some "{}" but still i wont work how i want to.

enter code here: namespace Quiz { class Program { static void Main(string[] args) { Console.Write("Enter Your name: "); string name = Console.ReadLine(); name = name.Substring(0, 1).ToUpper() + name.Substring(1).ToLower(); if (name == "Dennis" || name == "Denis") { Console.WriteLine("Hello " + name + " Psikopaki"); Console.WriteLine("This is quiz where i ask you question about myself and you need to find the correct answer."); Console.WriteLine("Rules: At first you will asked 10 easy ones, if you are correct "); Console.WriteLine("in more then 8 question you allowed to enter the hard mode."); Console.WriteLine("Those easy ones contains just simple question while the hard ones more deeper question about myself."); Console.WriteLine("Just type the letter a-c who you think is the right one for the answer.");

            Console.Write("Did you understand anything and wants to start the quiz:(Yes or No) ");
            string answer8 = Console.ReadLine();
            answer8 = answer8.Substring(0, 1).ToUpper() + answer8.Substring(1).ToLower();



            if (answer8 == "Yes")
            {
                string q1 = "What is my favorite color?\n" + "(a)Blue\n" + "(b)black\n" + "(c)Green\n";
                string q2 = "What is my favorite movie?\n" + "(a)Ip Man\n" + "(b)Koe no Katachi/A silence voice\n" + "(c)I am Sam\n";
                string q3 = "What is my favorite sport?\n" + "(a)Basketball\n" + "(b)Football\n" + "(c)F UR hokasan\n";
                string q4 = "What is my favorite singer(ALB)?\n" + "(a)Unikkatil\n" + "(b)Alban Skenderaj\n" + "(c)Yll Limani\n";
                string q5 = "What is my favorite singer(INT)?\n" + "(a)Katy Perry\n" + "(b)Lady Gaga\n" + "(c)Eminem\n";
                string q6 = "Which team do i support in sport?\n" + "(a)That team that ur Hokasan plays\n" + "(b)Chelsea\n" + "(c)Inter\n";
                string q7 = "What is my favorite animal?\n" + "(a)Penguin\n" + "(b)Dog\n" + "(c)Lion\n";
                string q8 = "What is my favorite anime?\n" + "(a)Bleach\n" + "(b)Boku no Pico\n" + "(c)Toradora\n";
                string q9 = "Where do you think i would want to live?\n" + "(a)Bobs and Vegana\n" + "(b)USA\n" + "(c)Japan\n";
                string q10 = "My favorite song?\n" + "(a)Eklips\n" + "(b)Firework\n" + "(c)Love the way you lie\n";
                Question[] questions =
                {
            new Question(q1,"c"),
            new Question(q2,"a"),
             new Question(q3,"b"),
              new Question(q4,"b"),
               new Question(q5,"b"),
                new Question(q6,"c"),
                 new Question(q7,"a"),
                  new Question(q8,"a"),
                   new Question(q9,"c"),
                    new Question(q10,"a")};

                int score = 0;
                for (int i = 0; i < questions.Length; i++)
                {
                    Console.WriteLine(questions[i].prompt);
                    string answer = Console.ReadLine();
                    answer = answer.ToLower();
                    if (answer == questions[i].answer)
                    {
                        score++;
                    }
                }
                Console.WriteLine("You got" + score + "/" + questions.Length);
                Console.ReadLine();
                if (score <= 7)
                {
                    Console.WriteLine("Thank you participating to the quiz i hope you did enjojy it.");
                    Console.WriteLine("Do you want to start over again so maybe you will unlock the hard mode?(Yes or No) ");
                    string antwort = Console.ReadLine();
                    antwort = antwort.Substring(0, 1).ToUpper() + antwort.Substring(1).ToLower();
                    if (antwort == "Yes")
                    {
                        Main(args);
                    }
                    if (antwort == "No")
                    {
                        Console.WriteLine("Still thank you for participating :D ");
                        Console.ReadLine();
                        Environment.Exit(0);
                    }
                    else
                    {
                        Console.WriteLine("Invalid input you morron");
                        Console.ReadLine();
                    }
                }
                if (score <= 8)
                {
                    Console.WriteLine("Go kill yourself se kurr ma disapointment sjom kon ");
                    Console.ReadLine();
                    Environment.Exit(0);
                }
                if (score >= 8)
                {
                    Console.WriteLine("Now you have unlocked the hard mode congrutalions");
                    Console.WriteLine("Should we continue: (Yes or No) ");
                    string answer2 = Console.ReadLine();
                    answer2 = answer2.Substring(0, 1).ToUpper() + answer2.Substring(1).ToLower();


                    if (answer2 == "Yes")
                    {
                        string p1 = "What am I most afraid of?\n" + "(a)Dying without finishing my goals\n" + "(b)Death in general\n" + "(c)Being not able to help people who has a big value to me\n";
                        string p2 = " If I could do anything for the rest of my life, what would that be??\n" + "(a)Spent time with family/friends\n" + "(b)Help around the world\n" + "(c)Play football\n";
                        string p3 = "Would I rather go to space or to the bottom of the ocean?\n" + "(a)Ocean\n" + "(b)Space\n" + "(c)Neither one/both ones\n";
                        string p4 = "How many children do you think i want in the future?\n" + "(a)2\n" + "(b)4\n" + "(c)6\n";
                        string p5 = "If I could be an animal, which one I would like to be?\n" + "(a)Lion\n" + "(b)Bird\n" + "(c)Penguin\n";
                        string p6 = "When i was little, what did i want to be?\n" + "(a)Doctor\n" + "(b)Football Player\n" + "(c)Pilot\n";
                        string p7 = "How do i relieve stress?\n" + "(a)By walking\n" + "(b)By crushing things\n" + "(c)By hurting myself\n";
                        string p8 = "Would would i rather do?\n" + "(a)Kill a person\n" + "(b)Cheat\n" + "(c)Lie\n";
                        string p9 = "What is one thing you regret having done or not done in your life?\n" + "(a)Talking/spending time with the wrong person\n" + "(b)Nothing\n" + "(c)One specific embarrasing thing\n";
                        string p10 = "When was the last time you cried?\n" + "(a)Within 5 years\n" + "(b)Within 10 years\n" + "(c)Within 20 years\n";
                        Question[] questions2 =
                        {
            new Question(p1,"a"),
            new Question(p2,"b"),
             new Question(p3,"c"),
              new Question(p4,"c"),
               new Question(p5,"b"),
                new Question(p6,"b"),
                 new Question(p7,"a"),
                  new Question(p8,"b"),
                   new Question(p9,"b"),
                    new Question(p10,"c")};

                        int score1 = 0;
                        for (int i = 0; i < questions2.Length; i++)
                        {
                            Console.WriteLine(questions2[i].prompt);
                            string answer3 = Console.ReadLine();
                            answer3 = answer3.ToLower();
                            if (answer3 == questions2[i].answer)
                            {
                                score1++;
                            }
                        }
                        if (score1 <= 5)
                        {
                            Console.WriteLine("You got" + score1 + "/" + questions.Length);
                            Console.WriteLine("Rezultati i \"knaqshem\"");
                            Console.ReadLine();
                            Environment.Exit(0);
                        }
                        if (score1 >= 6 && score1 <= 9)
                        {
                            Console.WriteLine("You got" + score1 + "/" + questions.Length);
                            Console.WriteLine("Maybe i should thinking about marrying you <3 <3 <3");
                            Console.ReadLine();
                            Environment.Exit(0);
                        }
                        if (score1 == 10)
                        {
                            Console.WriteLine("You got" + score1 + "/" + questions.Length);
                            Console.WriteLine("Would you marry me?(Yes or No) <3 <3 <3");
                            string martesa = Console.ReadLine();
                            martesa = martesa.Substring(0, 1).ToUpper() + martesa.Substring(1).ToLower();

                            if (martesa == "Yes" || martesa == "Po")
                            {
                                Console.WriteLine("I love you " + name);
                                Console.ReadLine();
                                Environment.Exit(0);
                            }
                            if (martesa == "No" || martesa == "Jo")
                            {
                                Console.WriteLine("Jumping from the bridge emonji ");
                                Console.ReadLine();
                                Environment.Exit(0);
                            }
                        }

                    }

                }
            }

            if (name != "Dennis")
            {
                Console.WriteLine("Hello " + name);
                Console.WriteLine("This is quiz where i ask you question about myself and you need to find the correct answer.");
                Console.WriteLine("Rules: At first you will asked 10 easy ones, if you are correct ");
                Console.WriteLine("in more then 8 question you allowed to enter the hard mode.");
                Console.WriteLine("Those easy ones contains just simple question while the hard ones more deeper question about myself.");
                Console.WriteLine("Just type the letter a-c who you think is the right one for the answer.");

                Console.Write("Did you understand anything and wants to start the quiz:(Yes or No) ");
                string answer10 = Console.ReadLine();
                answer10 = answer10.Substring(0, 1).ToUpper() + answer10.Substring(1).ToLower();



                if (answer10 == "Yes")
                {
                    string q1 = "What is my favorite color?\n" + "(a)Blue\n" + "(b)black\n" + "(c)Green\n";
                    string q2 = "What is my favorite movie?\n" + "(a)Ip Man\n" + "(b)Koe no Katachi/A silence voice\n" + "(c)I am Sam\n";
                    string q3 = "What is my favorite sport?\n" + "(a)Basketball\n" + "(b)Football\n" + "(c)Tennis\n";
                    string q4 = "What is my favorite singer(ALB)?\n" + "(a)Unikkatil\n" + "(b)Alban Skenderaj\n" + "(c)Yll Limani\n";
                    string q5 = "What is my favorite singer(INT)?\n" + "(a)Katy Perry\n" + "(b)Lady Gaga\n" + "(c)Eminem\n";
                    string q6 = "Which team do i support in sport?\n" + "(a)Barcelona\n" + "(b)Chelsea\n" + "(c)Inter\n";
                    string q7 = "What is my favorite animal?\n" + "(a)Penguin\n" + "(b)Dog\n" + "(c)Lion\n";
                    string q8 = "What is my favorite anime?\n" + "(a)Bleach\n" + "(b)Death Note\n" + "(c)Toradora\n";
                    string q9 = "Where do you think i would want to live?\n" + "(a)Germany\n" + "(b)USA\n" + "(c)Japan\n";
                    string q10 = "My favorite song?\n" + "(a)Eklips\n" + "(b)Firework\n" + "(c)Love the way you lie\n";
                    Question[] questions =
                    {
            new Question(q1,"c"),
            new Question(q2,"a"),
             new Question(q3,"b"),
              new Question(q4,"b"),
               new Question(q5,"b"),
                new Question(q6,"c"),
                 new Question(q7,"a"),
                  new Question(q8,"a"),
                   new Question(q9,"c"),
                    new Question(q10,"a")};

                    int score = 0;
                    for (int i = 0; i < questions.Length; i++)
                    {
                        Console.WriteLine(questions[i].prompt);
                        string answer = Console.ReadLine();
                        answer = answer.ToLower();
                        if (answer == questions[i].answer)
                        {
                            score++;
                        }
                    }
                    Console.WriteLine("You got" + score + "/" + questions.Length);
                    Console.ReadLine();
                    if (score <= 7)
                    {
                        Console.WriteLine("Thank you participating to the quiz i hope you did enjojy it.");
                        Console.WriteLine("Do you want to start over again so maybe you will unlock the hard mode?(Yes or No) ");
                        string antwort = Console.ReadLine();
                        antwort = antwort.Substring(0, 1).ToUpper() + antwort.Substring(1).ToLower();
                        if (antwort == "Yes")
                        {
                            Main(args);
                        }
                        if (antwort == "No")
                        {
                            Console.WriteLine("Still thank you for participating :D ");
                            Console.ReadLine();
                            Environment.Exit(0);
                        }
                        else
                        {
                            Console.WriteLine("Invalid input you morron");
                            Console.ReadLine();
                        }
                    }
                    if (score >= 8)
                    {
                        Console.WriteLine("Now you have unlocked the hard mode congrutalions");
                        Console.WriteLine("Should we continue: (Yes or No) ");
                        string answer2 = Console.ReadLine();
                        answer2 = answer2.Substring(0, 1).ToUpper() + answer2.Substring(1).ToLower();


                        if (answer2 == "Yes")
                        {
                            string p1 = "What am I most afraid of?\n" + "(a)Dying without finishing my goals\n" + "(b)Death in general\n" + "(c)Being not able to help people who has a big value to me\n";
                            string p2 = " If I could do anything for the rest of my life, what would that be??\n" + "(a)Spent time with family/friends\n" + "(b)Help around the world\n" + "(c)Play football\n";
                            string p3 = "Would I rather go to space or to the bottom of the ocean?\n" + "(a)Ocean\n" + "(b)Space\n" + "(c)Neither one/both ones\n";
                            string p4 = "How many children do you think i want in the future?\n" + "(a)2\n" + "(b)4\n" + "(c)6\n";
                            string p5 = "If I could be an animal, which one I would like to be?\n" + "(a)Lion\n" + "(b)Bird\n" + "(c)Penguin\n";
                            string p6 = "When i was little, what did i want to be?\n" + "(a)Doctor\n" + "(b)Football Player\n" + "(c)Pilot\n";
                            string p7 = "How do i relieve stress?\n" + "(a)By walking\n" + "(b)By crushing things\n" + "(c)By hurting myself\n";
                            string p8 = "Would would i rather do?\n" + "(a)Kill a person\n" + "(b)Cheat\n" + "(c)Lie\n";
                            string p9 = "What is one thing you regret having done or not done in your life?\n" + "(a)Talking/spending time with the wrong person\n" + "(b)Nothing\n" + "(c)One specific embarrasing thing\n";
                            string p10 = "When was the last time you cried?\n" + "(a)Within 5 years\n" + "(b)Within 10 years\n" + "(c)Within 20 years\n";
                            Question[] questions2 =
                            {
            new Question(p1,"a"),
            new Question(p2,"b"),
             new Question(p3,"c"),
              new Question(p4,"c"),
               new Question(p5,"b"),
                new Question(p6,"b"),
                 new Question(p7,"a"),
                  new Question(p8,"b"),
                   new Question(p9,"b"),
                    new Question(p10,"c")};

                            int score1 = 0;
                            for (int i = 0; i < questions2.Length; i++)
                            {
                                Console.WriteLine(questions2[i].prompt);
                                string answer3 = Console.ReadLine();
                                answer3 = answer3.ToLower();
                                if (answer3 == questions2[i].answer)
                                {
                                    score1++;
                                }
                            }
                            if (score1 <= 5)
                            {
                                Console.WriteLine("You got" + score1 + "/" + questions.Length);
                                Console.WriteLine("Rezultati i knaqshem");
                                Console.ReadLine();
                                Environment.Exit(0);
                            }
                            if (score1 >= 6 && score1 <= 9)
                            {
                                Console.WriteLine("You got" + score1 + "/" + questions.Length);
                                Console.WriteLine("Maybe i should thinking about marrying you <3 <3 <3");
                                Console.ReadLine();
                                Environment.Exit(0);
                            }
                            if (score1 == 10)
                            {
                                Console.WriteLine("You got" + score1 + "/" + questions.Length);
                                Console.WriteLine("Would you marry me?(Yes or No) <3 <3 <3");
                                string martesa = Console.ReadLine();
                                martesa = martesa.Substring(0, 1).ToUpper() + martesa.Substring(1).ToLower();

                                if (martesa == "Yes" || martesa == "Po")
                                {
                                    Console.WriteLine("I love you " + name);
                                    Console.ReadLine();
                                    Environment.Exit(0);
                                }
                                if (martesa == "No" || martesa == "Jo")
                                {
                                    Console.WriteLine("Jumping from the bridge emonji ");
                                    Console.ReadLine();
                                    Environment.Exit(0);
                                }
                            }

                        }

                    }

                }
                if (answer10 == "No")
                {
                    Rules();
                    if (answer10 == "No")
                    {
                        Main(args);
                    }
                }
                else
                {
                    Console.WriteLine("Invalid Input");
                    Console.ReadLine();
                    Console.WriteLine("Do you want to start over again:(Po ose Jo) ");
                    string ans = Console.ReadLine();
                    ans = ans.Substring(0, 1).ToUpper() + ans.Substring(1).ToLower();
                    if (ans == "Po" || ans == "Yes")
                    {
                        Main(args);
                    }
                    if (ans == "Jo" || ans == "No")
                    {
                        Console.WriteLine("Why not (Sad Emonji) ");

                        Console.ReadLine();
                        Environment.Exit(0);
                    }


                    else
                    {
                        Console.WriteLine("Again Invalid Input");
                        Console.WriteLine("Shame on you ");

                        Console.ReadLine();
                        Environment.Exit(0);
                    }
                }

            }
        }
    }
    //qetu me venods qata nese duhet
    public static void Rules()
    {
        Console.WriteLine("This is quiz where i ask you question about myself and you need to find the correct answer.");
        Console.WriteLine("Rules: At first you will asked 10 easy ones, if you are correct ");
        Console.WriteLine("in more then 8 question you allowed to enter the hard mode.");
        Console.WriteLine("Those easy ones contains just simple question while the hard ones more deeper question about myself.");
        Console.WriteLine("Just type the letter a-c who you think is the right one for the answer.");

        Console.Write("Did you understand anything and wants to start the quiz:(Yes or No) ");
        string answer1 = Console.ReadLine();
        answer1 = answer1.Substring(0, 1).ToUpper() + answer1.Substring(1).ToLower();

    }

}

}

When i enter another name it just terminated the command prompt.I dont want that to happen.And i thing somewhere a "{}" is to much or to less but i dont know where

Aucun commentaire:

Enregistrer un commentaire