Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace mainSolution
- {
- class Point
- {
- private int x, y;
- private double Sqr(int x) => x * x;
- public Point(int x, int y)
- {
- this.x = x;
- this.y = y;
- }
- public Point() => x = y = 0;
- public void Print()
- {
- Console.WriteLine(x + " " + y);
- }
- public double Range()
- {
- return Math.Sqrt(Sqr(x) + Sqr(y));
- }
- public void move(int a, int b)
- {
- x += a;
- y += b;
- }
- public int X
- {
- get =>x;
- set => x = value;
- }
- public int Y
- {
- get => y;
- set => y = value;
- }
- public int Mult
- {
- set
- {
- x *= value;
- y *= value;
- }
- }
- public int this[int index]//индексатор
- {
- get
- {
- try
- {
- if (index > 1)
- throw new Exception();
- }
- catch(Exception ex)
- {
- Console.WriteLine("index of Point can't be more than 1");
- System.Environment.Exit(1);
- }
- return index == 0 ? x : y;
- }
- }
- public static Point operator ++(Point p)
- {
- return new Point(++p.x, ++p.y);
- }
- public static Point operator --(Point p)
- {
- return new Point(--p.x, --p.y);
- }
- public static bool operator true(Point a)//перегрузка констант true и false
- {
- return a.x == a.y ? true : false;
- }
- public static bool operator false(Point a)//перегрузка констант true и false
- {
- return a.x == a.y ? true : false;
- }
- public static Point operator +(Point a, int b)//перегрузка оператора '!'
- {
- a.x += b;
- a.y += b;
- return a;
- }
- }
- static class Program
- {
- static void Main(string[] args)
- {
- Point a = new Point(2, 3);
- a += 3;
- a.Print();
- }
- }
- }
Add Comment
Please, Sign In to add comment