Guest User

Untitled

a guest
Feb 21st, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace DAF1
  7. {
  8.     public class Point
  9.     {
  10.         public int x, y, sx, sy;
  11.  
  12.         public Point(int x, int y)
  13.         {
  14.             this.x = x;
  15.             this.y = y;
  16.         }
  17.  
  18.         public int GetX()
  19.         {
  20.             return x;
  21.         }
  22.        
  23.         public int GetY()
  24.         {
  25.             return y;
  26.         }
  27.  
  28.         public int SetX(int sx)
  29.         {
  30.             this.x = sx;
  31.             return x;
  32.         }
  33.  
  34.         public int SetY(int sy)
  35.         {
  36.             this.y = sy;
  37.             return y;
  38.         }
  39.  
  40.         public override string ToString()
  41.         {
  42.             return "(<"+x+">, <"+y+">)";
  43.         }
  44.  
  45.         public double Distance(Point p)
  46.         {
  47.             return Math.Sqrt(Math.Pow((x - p.GetX()), 2) + Math.Pow((y - p.GetY()), 2));
  48.         }
  49.  
  50.         public Point Middle(Point p)
  51.         {
  52.             Point middle = new Point((x + p.GetX()) / 2, (y + p.GetY()) / 2);
  53.             return middle;
  54.         }
  55.     }
  56. }
Add Comment
Please, Sign In to add comment