rivalcoba

doble exec

Apr 30th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.06 KB | None | 0 0
  1. using System;
  2. using static System.Console;
  3. namespace Challenge
  4. {
  5.     class Program
  6.     {
  7.         int x1, x2, x3, x4, x5, x6;
  8.         int y1, y2, y3, y4, y5, y6;
  9.         string desicion;
  10.         bool result1, result2;
  11.         public void RequestData()
  12.         {
  13.             Clear();
  14.             WriteLine("Ingrese los datos solicitados");
  15.             WriteLine("Ingrese las \"x\" y \"y\" del primer cuadrado");
  16.             WriteLine("Ingrese x1");
  17.             x1 = int.Parse(ReadLine());
  18.             WriteLine("Ingrese y1");
  19.             y1 = int.Parse(ReadLine());
  20.             WriteLine("Ingrese x2");
  21.             x2 = int.Parse(ReadLine());
  22.             WriteLine("Ingrese y2");
  23.             y2 = int.Parse(ReadLine());
  24.             WriteLine("Ingrese las \"x\" y \"y\" del segundo cuadrado");
  25.             WriteLine("Ingrese x3");
  26.             x3 = int.Parse(ReadLine());
  27.             WriteLine("Ingrese y3");
  28.             y3 = int.Parse(ReadLine());
  29.             WriteLine("Ingrese x4");
  30.             x4 = int.Parse(ReadLine());
  31.             WriteLine("Ingrese y4");
  32.             y4 = int.Parse(ReadLine());
  33.             MaximousAndMinimous();
  34.         }
  35.         public void MaximousAndMinimous()
  36.         {
  37.             if(x1 > x3)
  38.             {
  39.                 x5 = x1;
  40.             }
  41.             else
  42.             {
  43.                 x5 = x3;
  44.             }
  45.             if(y1 > y3)
  46.             {
  47.                 y5 = y1;
  48.             }
  49.             else
  50.             {
  51.                 y5 = y3;
  52.             }
  53.             if(x2 < x4)
  54.             {
  55.                 x6 = x2;
  56.             }
  57.             else
  58.             {
  59.                 x6 = x4;
  60.             }
  61.             if(y2 < y4)
  62.             {
  63.                 y6 = y2;
  64.             }
  65.             else
  66.             {
  67.                 y6 = y4;
  68.             }
  69.             ExtremeCase1();
  70.         }
  71.         public void ExtremeCase1()
  72.         {
  73.             if(x5 > x6)
  74.             {
  75.                 WriteLine("ExtremeCase1: Aqui no se forma un rectangulo");
  76.                 WriteLine("LOG> Se invoca a Restart desde ln76");
  77.                 Restart();
  78.             }
  79.             else if (y5 > y6)
  80.             {
  81.                 WriteLine("ExtremeCase1: Aqui no se forma un rectangulo");
  82.                 WriteLine("LOG> Se invoca a Restart desde ln82");
  83.                 Restart();
  84.             }
  85.             ExtremeCase2();
  86.         }
  87.         public void ExtremeCase2()
  88.         {
  89.             if(x5 == x6)
  90.             {
  91.                 WriteLine("ExtremeCase2: Aqui no se forma un rectangulo");
  92.                 WriteLine("LOG> Se invoca a Restart desde ln92");
  93.                 Restart();
  94.             }
  95.             else if (y5 == y6)
  96.             {
  97.                 WriteLine("ExtremeCase1: Aqui no se forma un rectangulo");
  98.                 WriteLine("LOG> Se invoca a Restart desde ln98");
  99.                 Restart();
  100.             }
  101.             else
  102.             {
  103.                 Result();
  104.             }
  105.         }
  106.         public void Result()
  107.         {
  108.             WriteLine("Las intersecciones encontradas son:");
  109.             WriteLine("Interseccion 1: ({0},{1})",x5 ,y5);
  110.             WriteLine("Interseccion 2: ({0},{1})",x6 ,y6);
  111.             WriteLine("LOG> Se invoca a Restart desde Result ln111");
  112.             Restart();
  113.         }
  114.         public void Restart()
  115.         {
  116.             WriteLine("¿Desea calcular otra interseccion?");
  117.             WriteLine("1. Si");
  118.             WriteLine("2. No");
  119.             desicion = ReadLine().ToUpper();
  120.             switch (desicion)
  121.             {
  122.                 case "1":
  123.                 case "SI":
  124.                 RequestData();
  125.                 break;
  126.                 default:
  127.                 WriteLine("LOG> Entra a default!!!");
  128.                 EndProgram();
  129.                 break;
  130.             }
  131.         }
  132.         public void EndProgram()
  133.         {
  134.             WriteLine("Hasta pronto....");
  135.         }
  136.        
  137.         static void Main(string[] args)
  138.         {
  139.             Program Request = new Program();
  140.             Request.RequestData();
  141.         }
  142.     }
  143. }
Add Comment
Please, Sign In to add comment