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 abcd
- {
- class MyPoint
- {
- private
- int x, y;
- public
- MyPoint()
- {
- x = 0;
- y = 0;
- }
- MyPoint(int a, int b)
- {
- x = a;
- y = b;
- }
- int GetterX()
- {
- return x;
- }
- int GetterY()
- {
- return y;
- }
- void SetterX(int a)
- {
- x = a;
- }
- void SetterY(int b)
- {
- y = b;
- }
- string toString()
- {
- return string.Format("({0},{1})", x, y);
- }
- double distance(int a, int b)
- {
- return Math.Sqrt(Math.Pow((a-x),2)+Math.Pow((b-y),2));
- }
- double distance(MyPoint b){
- return Math.Sqrt(Math.Pow((b.x-x),2)+Math.Pow((b.y-y),2));
- }
- double distance(){
- return Math.Sqrt(Math.Pow(x,2)+Math.Pow(y,2));
- }
- static void Main(string[] args)
- {
- MyPoint a = new MyPoint(3,4);
- MyPoint b = new MyPoint(2,5);
- Console.WriteLine("toString :{0}", a.toString());
- double x=a.distance(b);
- Console.WriteLine("Khoang Cach {0}", x);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement