Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using static System.Console;
- namespace Challenge
- {
- class Program
- {
- int x1, x2, x3, x4, x5, x6;
- int y1, y2, y3, y4, y5, y6;
- string desicion;
- bool result1, result2;
- public void RequestData()
- {
- Clear();
- WriteLine("Ingrese los datos solicitados");
- WriteLine("Ingrese las \"x\" y \"y\" del primer cuadrado");
- WriteLine("Ingrese x1");
- x1 = int.Parse(ReadLine());
- WriteLine("Ingrese y1");
- y1 = int.Parse(ReadLine());
- WriteLine("Ingrese x2");
- x2 = int.Parse(ReadLine());
- WriteLine("Ingrese y2");
- y2 = int.Parse(ReadLine());
- WriteLine("Ingrese las \"x\" y \"y\" del segundo cuadrado");
- WriteLine("Ingrese x3");
- x3 = int.Parse(ReadLine());
- WriteLine("Ingrese y3");
- y3 = int.Parse(ReadLine());
- WriteLine("Ingrese x4");
- x4 = int.Parse(ReadLine());
- WriteLine("Ingrese y4");
- y4 = int.Parse(ReadLine());
- MaximousAndMinimous();
- }
- public void MaximousAndMinimous()
- {
- if(x1 > x3)
- {
- x5 = x1;
- }
- else
- {
- x5 = x3;
- }
- if(y1 > y3)
- {
- y5 = y1;
- }
- else
- {
- y5 = y3;
- }
- if(x2 < x4)
- {
- x6 = x2;
- }
- else
- {
- x6 = x4;
- }
- if(y2 < y4)
- {
- y6 = y2;
- }
- else
- {
- y6 = y4;
- }
- ExtremeCase1();
- }
- public void ExtremeCase1()
- {
- if(x5 > x6)
- {
- WriteLine("ExtremeCase1: Aqui no se forma un rectangulo");
- WriteLine("LOG> Se invoca a Restart desde ln76");
- Restart();
- }
- else if (y5 > y6)
- {
- WriteLine("ExtremeCase1: Aqui no se forma un rectangulo");
- WriteLine("LOG> Se invoca a Restart desde ln82");
- Restart();
- }
- ExtremeCase2();
- }
- public void ExtremeCase2()
- {
- if(x5 == x6)
- {
- WriteLine("ExtremeCase2: Aqui no se forma un rectangulo");
- WriteLine("LOG> Se invoca a Restart desde ln92");
- Restart();
- }
- else if (y5 == y6)
- {
- WriteLine("ExtremeCase1: Aqui no se forma un rectangulo");
- WriteLine("LOG> Se invoca a Restart desde ln98");
- Restart();
- }
- else
- {
- Result();
- }
- }
- public void Result()
- {
- WriteLine("Las intersecciones encontradas son:");
- WriteLine("Interseccion 1: ({0},{1})",x5 ,y5);
- WriteLine("Interseccion 2: ({0},{1})",x6 ,y6);
- WriteLine("LOG> Se invoca a Restart desde Result ln111");
- Restart();
- }
- public void Restart()
- {
- WriteLine("¿Desea calcular otra interseccion?");
- WriteLine("1. Si");
- WriteLine("2. No");
- desicion = ReadLine().ToUpper();
- switch (desicion)
- {
- case "1":
- case "SI":
- RequestData();
- break;
- default:
- WriteLine("LOG> Entra a default!!!");
- EndProgram();
- break;
- }
- }
- public void EndProgram()
- {
- WriteLine("Hasta pronto....");
- }
- static void Main(string[] args)
- {
- Program Request = new Program();
- Request.RequestData();
- }
- }
- }
Add Comment
Please, Sign In to add comment