vendredi 18 septembre 2020

How should I make my "goto" not to run at the end?

Hello! :D So, I have this code below. It is working but I would not say that it works the way I want it to work. So, I used goto to jump to the end of the code. But at the last stage of if I have a goto that navigates to igen: Console.WriteLine("Remek! Estre 8-ra érted megyek!");. When this case happens, I do not want the code below ( nem: Console.WriteLine("Kár, pedig szívesen elhívtalak volna randizni. :(");) to run. How can I get this to work? Thank you in advance!

using System.Reflection.Emit;

namespace Randi
{
    class Program
    {

        static void Main(string[] args)
        {
            Console.WriteLine("Hány centi vagy?");

            int cm = int.Parse(Console.ReadLine());
            if (cm <= 175 && cm >= 150);
            else goto nem;
            {
                Console.WriteLine("Naa, tök jó! Az alacsony lányok cukik.");
                Console.WriteLine("Hány éves vagy?");
                int év = int.Parse(Console.ReadLine());
                if (év <= 18 && év >= 16);
                else goto nem;
                {
                    Console.WriteLine("Akkor még korban is összepasszolunk!");
                    Console.WriteLine("Van barátod?");
                    
                    string kapcsolat = Console.ReadLine();
                    if (kapcsolat.Contains("Nincs"));
                    else goto nem;
                    {
                        Console.WriteLine("Örülök neki! Eljönnél velem randizni? (Igen/Nem)");

                        string randi = Console.ReadLine();
                        if (randi.Contains("Igen")) goto igen;
                        else goto nem;
                    } 
                        
                }
            
            }
        igen:
            Console.WriteLine("Remek! Estre 8-ra érted megyek!");
        nem:
            Console.WriteLine("Kár, pedig szívesen elhívtalak volna randizni. :(");

            Console.ReadKey();
        }

    }
}

Aucun commentaire:

Enregistrer un commentaire