Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _3D
- {
- class Point3D
- {
- int x;
- public int X
- {
- get
- {
- return x;
- }
- set
- {
- try
- {
- if (value < 0)
- {
- throw new Exception("x не должен быть меньше нуля");
- }
- else { x = value; }
- }
- catch (Exception e)
- {
- Console.WriteLine("Ошибка:" + e.Message);
- }
- }
- }
- int y;
- public int Y
- {
- get
- {
- return y;
- }
- set
- {
- try
- {
- if (value < 0)
- {
- throw new Exception("y не должен быть меньше нуля");
- }
- if (value > 100)
- {
- throw new Exception("y не должен быть больше 100");
- }
- y = value;
- }
- catch (Exception e)
- {
- if (value > 100)
- {
- y = 100;
- }
- Console.WriteLine("Ошибка:" + e.Message);
- }
- }
- }
- int z;
- public int Z{
- get
- {
- return Z;
- }
- set
- {
- try
- {
- if (value > (x + y))
- {
- throw new Exception("z не должен быть больше чем сумма x и y");
- }
- else
- {
- z = value;
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("Ошибка:" + e.Message);
- }
- }
- }
- public Point3D()
- {
- }
- int Multiply
- {
- set
- {
- x *= value;
- y *= value;
- z *= value;
- }
- }
- public Point3D(int x, int y, int z)
- {
- try
- {
- if (x % 5 == 0 || y % 5 == 0 || z % 5 == 0)
- {
- this.z = z;
- this.x = x;
- this.y = y;
- }
- else throw new Exception("Ни ода из точек не делится на пять.");
- }
- catch(Exception e)
- {
- Console.WriteLine("Ошибка:" + e.Message);
- //Point3D temp;
- do
- {
- Console.WriteLine("X, Y, Z:");
- this.x = int.Parse(Console.ReadLine());
- this.y = int.Parse(Console.ReadLine());
- this.z = int.Parse(Console.ReadLine());
- } while (this.x % 5 != 0 && this.y % 5 != 0 && this.z % 5 != 0);
- //temp = new Point3D(int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()), int.Parse(Console.ReadLine()));
- //this.x = temp.X;
- //this.y = temp.Y;
- //this.z = temp.Z;
- }
- }
- public void Move(char type, byte amount)
- {
- if (type == 'x')
- {
- x = amount;
- }
- else
- {
- if (type == 'y')
- {
- y = amount;
- }
- else
- {
- z = amount;
- }
- }
- }
- public void CrdPrint()
- {
- Console.WriteLine("x:{0} y:{1} z:{2}", x, y, z);
- }
- public float RadiusVector()
- {
- return (float)Math.Sqrt(x * x + y * y + z * z);
- }
- public void Sum(Point3D ob)
- {
- this.z += ob.z;
- x += ob.x;
- y += ob.y;
- }
- public void Sum(int x,int y,int z)
- {
- this.z += z;
- this.x += x;
- this.y += y;
- }
- }
- class Paral
- {
- int x;
- int y;
- //int z;
- int height;
- int width;
- int length;
- public Paral()
- {
- x = 0;
- y = 0;
- //z = 0;
- height = 5;
- length = 7;
- width = 6;
- }
- public Paral(int height, int width, int length, int x, int y)
- {
- this.height = height;
- this.width = width;
- this.length = length;
- this.x = x;
- this.y = y;
- //this.z = z;
- }
- public int getLength()
- {
- return length;
- }
- public int getWidth()
- {
- return width;
- }
- public int getHeight()
- {
- return height;
- }
- public int getArea()
- {
- return 2 * height * width + 2 * width * length + 2 * length * height;
- }
- public int getVolume()
- {
- return height * width * length;
- }
- public int getx()
- {
- return x;
- }
- public int gety()
- {
- return y;
- }
- public void showDimensions()
- {
- Console.WriteLine("Width:{0} Length:{1} Height{2}", width, length, height);
- }
- public bool IntersectionCheck(Paral ob)
- {
- if ((ob.getx() < (x + length) && ob.getx() > x) && (ob.gety() < (y + width) && ob.gety() > y))
- {
- return true;
- }
- if ((ob.getx() + ob.getLength() <= (x + length) && (ob.getx() + ob.getLength()) >= x) && (ob.gety() < (y + width) && ob.gety() >= y))
- return true;
- if ((ob.getx() + ob.getLength() <= (x + length) && (ob.getx() + ob.getLength()) >= x) && ob.gety() + ob.getWidth() >= y && ob.gety() + ob.getWidth() <= (y + width))
- return true;
- return false;
- }
- public void getUnionSize(Paral ob)
- {
- int width_union = 0;
- int length_union = 0;
- if (IntersectionCheck(ob))
- {
- if (ob.getx() < (x + length))
- {
- //if (ob.getx() >= x)
- //{
- if (ob.getx() + ob.getLength() > x + length)
- length_union = ob.getLength() - (ob.getx() + ob.getLength() - (x + length));
- else
- {
- if (ob.getx() < (x + length) && ob.getx() > x && ((ob.getx() + ob.length) < (x + length) && (ob.getx() + ob.length) > x))
- length_union = ob.getLength();
- else { length_union = ob.getx() + ob.getLength() - x; }
- //length_union = ob.getLength();
- }
- }
- else
- {
- length_union = ob.getx() + ob.length - x;
- }
- //}
- if (ob.gety() < (y + width))
- {
- if (ob.gety() + ob.getWidth() > y + width)
- //width_union = (y + width) - ob.gety();
- width_union = ob.getWidth() - (ob.gety() + ob.getWidth() - (y + width));
- else
- {
- if (ob.gety() < (y + width) && ob.gety() > y && ((ob.gety() + ob.getWidth()) < (y + width) && (ob.gety() + ob.getWidth()) > y))
- width_union = ob.getLength();
- else { width_union = ob.gety() + ob.getWidth() - y; }
- //width_union = ob.getWidth();
- }
- }
- else
- {
- width_union = ob.gety() + ob.width - y;
- }
- }
- Console.WriteLine(length_union + " " + width_union);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Point3D point = new Point3D(1, 2, 3);
- //Point3D point1 = new Point3D(0, 6, 30);
- //point.CrdPrint();
- //point.Sum(point1);
- //point.CrdPrint();
- //Paral first = new Paral(90, 6, 7, 0, 0);
- //while (true)
- //{
- // Console.WriteLine("Введите x и y:");
- // int x = int.Parse(Console.ReadLine());
- // int y = int.Parse(Console.ReadLine());
- // Paral second = new Paral(80, 2, 2, x, y);
- // first.getUnionSize(second);
- //}
- //Console.Read();
- Console.WriteLine("Test");
- Console.ReadLine();
- while (true)
- {
- point.X = int.Parse(Console.ReadLine());
- point.Y = int.Parse(Console.ReadLine());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement