Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.48 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp10
  8. {
  9. class CPoint
  10. {
  11. public int x;
  12. public int y;
  13. string name;
  14. public CPoint(int x, int y, string name) : this(x, y)
  15. {
  16. Name = name;
  17. }
  18. public CPoint(int x, int y) : this()
  19. {
  20. Set(x, y);
  21. }
  22. public CPoint()
  23. {
  24. Set(x, y);
  25. Name = "Unknown";
  26. }
  27. public void Set(int x, int y)
  28. {
  29. X = x;
  30. Y = y;
  31. }
  32. public override bool Equals(object obj)
  33. {
  34. if (obj == null) return false;
  35. CPoint a = obj as CPoint;
  36. if (a == null) return false;
  37. return (a.X == X && a.Y == Y);
  38. }
  39. public static bool operator ==(CPoint a, CPoint b)
  40. {
  41. return a.Equals(b);
  42. }
  43. public static bool operator !=(CPoint a, CPoint b)
  44. {
  45. return !a.Equals(b);
  46. }
  47. public int X
  48. {
  49. get { return x; }
  50. set { x = value; }
  51. }
  52. public int Y
  53. {
  54. get { return y; }
  55. set { y = value; }
  56. }
  57.  
  58. public string Name
  59. {
  60. get { return name; }
  61. set { name = value; }
  62. }
  63. }
  64. class CcoloredPoint : CPoint
  65. {
  66. string colorOfPoint;
  67. public CcoloredPoint(int x, int y, string name, string colorOfPoint) : base(x, y, name)
  68. {
  69. ColorOfPoint = colorOfPoint;
  70. }
  71. public CcoloredPoint(int x, int y) : this()
  72. {
  73. Set(x, y);
  74. }
  75. public CcoloredPoint() : base()
  76. {
  77. colorOfPoint = "black";
  78. }
  79.  
  80. public string ColorOfPoint
  81. {
  82. get { return colorOfPoint; }
  83. set { colorOfPoint = value; }
  84. }
  85.  
  86. }
  87.  
  88. class CLine
  89. {
  90. CPoint a;
  91. CPoint b;
  92. string name;
  93. public CLine(CPoint a, CPoint b, string name) : this(a, b)
  94. {
  95. Name = name;
  96. }
  97. public CLine(CPoint a, CPoint b) : this()
  98. {
  99. Set(a, b);
  100. }
  101. public CLine()
  102. {
  103. Set(new CPoint(0, 0), new CPoint(0, 1));
  104. Name = "Unknown";
  105. }
  106. public void Set(CPoint a, CPoint b)
  107. {
  108. A = a;
  109. B = b;
  110. }
  111. public static bool IsParallel(CLine a, CLine b)
  112. {
  113. if (a.Gradient() * b.Gradient() == 1)
  114. return true;
  115. else return false;
  116. }
  117. public static bool IsPerpendicular(CLine a, CLine b)
  118. {
  119. if (a.Gradient() == b.Gradient())
  120. return true;
  121. else return false;
  122. }
  123. /*public override bool Equals(object obj)
  124. {
  125. if (obj == null) return false;
  126. CLine m = obj as CLine;
  127. if (m == null) return false;
  128. float m1 = (float)(A.Y - a.Gradient() * A.X);
  129. float m2 = (float)(.y - b.Gradient() * b.x);
  130. return (k1 == k2);
  131. }*/
  132. /* public static bool Match(CLine a, CLine b)
  133. {
  134. if (a.Gradient() == b.Gradient())
  135. {
  136. if (A.Y - a.Gradient()*a.x == b.y - b.Gradient() * b.x)
  137. {
  138. return true;
  139. }
  140. }
  141. return false;
  142. }*/
  143. /*if (k1 == k2) {
  144. (они параллельны);
  145. if (y1 - k1x1 ==y2 - k2x2 ){
  146. (совпадают );
  147. }
  148. } */
  149. public override bool Equals(object obj)
  150. {
  151. if (obj == null) return false;
  152. CLine m = obj as CLine;
  153. if (m == null) return false;
  154. float m1 = (float)(A.Y - .Gradient() * A.X);
  155. float m2 = (float)(A.Y - a.Gradient() * A.X);
  156. return (m1 == m2);
  157. }
  158. public static bool operator ==(CLine a, CLine b)
  159. {
  160. return a.Equals(b);
  161. }
  162. public static bool operator !=(CLine a, CLine b)
  163. {
  164. return !a.Equals(b);
  165. }
  166. public CPoint A
  167. {
  168. get { return a; }
  169. set { a = value; }
  170. }
  171. public CPoint B
  172. {
  173. get { return b; }
  174. set { b = value; }
  175. }
  176. public string Name
  177. {
  178. get { return name; }
  179. set { name = value; }
  180. }
  181. public float Gradient()
  182. {
  183. return (float)(B.X - A.X) / (B.Y - A.Y);
  184. }
  185. }
  186. class CcoloredLine : CLine
  187. {
  188. string colorOfLine;
  189. public CcoloredLine(CPoint a, CPoint b, string name, string colorOfLine) : base(a, b, name)
  190. {
  191. ColorOfLine = colorOfLine;
  192. }
  193. public CcoloredLine(CPoint a, CPoint b) : this()
  194. {
  195. A = a;
  196. B = b;
  197. }
  198. public CcoloredLine() : base()
  199. {
  200. ColorOfLine = "black";
  201. }
  202. public string ColorOfLine
  203. {
  204. get { return colorOfLine; }
  205. set { colorOfLine = value; }
  206. }
  207.  
  208. }
  209.  
  210. class Program
  211. {
  212. static void Main(string[] args)
  213. {
  214. }
  215. }
  216. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement