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 ConsoleApp10
- {
- class CPoint
- {
- public int x;
- public int y;
- string name;
- public CPoint(int x, int y, string name) : this(x, y)
- {
- Name = name;
- }
- public CPoint(int x, int y) : this()
- {
- Set(x, y);
- }
- public CPoint()
- {
- Set(x, y);
- Name = "Unknown";
- }
- public void Set(int x, int y)
- {
- X = x;
- Y = y;
- }
- public override bool Equals(object obj)
- {
- if (obj == null) return false;
- CPoint a = obj as CPoint;
- if (a == null) return false;
- return (a.X == X && a.Y == Y);
- }
- public static bool operator ==(CPoint a, CPoint b)
- {
- return a.Equals(b);
- }
- public static bool operator !=(CPoint a, CPoint b)
- {
- return !a.Equals(b);
- }
- public int X
- {
- get { return x; }
- set { x = value; }
- }
- public int Y
- {
- get { return y; }
- set { y = value; }
- }
- public string Name
- {
- get { return name; }
- set { name = value; }
- }
- }
- class CcoloredPoint : CPoint
- {
- string colorOfPoint;
- public CcoloredPoint(int x, int y, string name, string colorOfPoint) : base(x, y, name)
- {
- ColorOfPoint = colorOfPoint;
- }
- public CcoloredPoint(int x, int y) : this()
- {
- Set(x, y);
- }
- public CcoloredPoint() : base()
- {
- colorOfPoint = "black";
- }
- public string ColorOfPoint
- {
- get { return colorOfPoint; }
- set { colorOfPoint = value; }
- }
- }
- class CLine
- {
- CPoint a;
- CPoint b;
- string name;
- public CLine(CPoint a, CPoint b, string name) : this(a, b)
- {
- Name = name;
- }
- public CLine(CPoint a, CPoint b) : this()
- {
- Set(a, b);
- }
- public CLine()
- {
- Set(new CPoint(0, 0), new CPoint(0, 1));
- Name = "Unknown";
- }
- public void Set(CPoint a, CPoint b)
- {
- A = a;
- B = b;
- }
- public static bool IsParallel(CLine a, CLine b)
- {
- if (a.Gradient() * b.Gradient() == 1)
- return true;
- else return false;
- }
- public static bool IsPerpendicular(CLine a, CLine b)
- {
- if (a.Gradient() == b.Gradient())
- return true;
- else return false;
- }
- /*public override bool Equals(object obj)
- {
- if (obj == null) return false;
- CLine m = obj as CLine;
- if (m == null) return false;
- float m1 = (float)(A.Y - a.Gradient() * A.X);
- float m2 = (float)(.y - b.Gradient() * b.x);
- return (k1 == k2);
- }*/
- /* public static bool Match(CLine a, CLine b)
- {
- if (a.Gradient() == b.Gradient())
- {
- if (A.Y - a.Gradient()*a.x == b.y - b.Gradient() * b.x)
- {
- return true;
- }
- }
- return false;
- }*/
- /*if (k1 == k2) {
- (они параллельны);
- if (y1 - k1x1 ==y2 - k2x2 ){
- (совпадают );
- }
- } */
- public override bool Equals(object obj)
- {
- if (obj == null) return false;
- CLine m = obj as CLine;
- if (m == null) return false;
- float m1 = (float)(A.Y - .Gradient() * A.X);
- float m2 = (float)(A.Y - a.Gradient() * A.X);
- return (m1 == m2);
- }
- public static bool operator ==(CLine a, CLine b)
- {
- return a.Equals(b);
- }
- public static bool operator !=(CLine a, CLine b)
- {
- return !a.Equals(b);
- }
- public CPoint A
- {
- get { return a; }
- set { a = value; }
- }
- public CPoint B
- {
- get { return b; }
- set { b = value; }
- }
- public string Name
- {
- get { return name; }
- set { name = value; }
- }
- public float Gradient()
- {
- return (float)(B.X - A.X) / (B.Y - A.Y);
- }
- }
- class CcoloredLine : CLine
- {
- string colorOfLine;
- public CcoloredLine(CPoint a, CPoint b, string name, string colorOfLine) : base(a, b, name)
- {
- ColorOfLine = colorOfLine;
- }
- public CcoloredLine(CPoint a, CPoint b) : this()
- {
- A = a;
- B = b;
- }
- public CcoloredLine() : base()
- {
- ColorOfLine = "black";
- }
- public string ColorOfLine
- {
- get { return colorOfLine; }
- set { colorOfLine = value; }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement