Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- Point _point1 = new Point("1point", 10, 10);
- Point _point2 = new Point(20, 30);
- Point _point3 = new Point("3point");
- Console.WriteLine(_point1.GetCoordsAndName); //result: (1point, 10, 10)
- Console.WriteLine(_point2.GetCoordsAndName); //result: (, 20, 30)
- Console.WriteLine(_point3.GetCoordsAndName); //result: (3point, 100, 300)
- }
- public class Point
- {
- private int x, y;
- private string name;
- public Point(int x, int y)
- {
- this.x = x;
- this.y = y;
- }
- public Point(string name) : this(100, 300)
- {
- this.name = name;
- }
- public Point(string name, int x, int y) : this(x, y)
- {
- this.name = name;
- }
- public (int,int) GetCoodrds() => (this.x,this.y);
- public string GetName() => this.name;
- public (string, int, int) GetCoordsAndName => (this.name, this.x, this.y);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement