The struct Point - mutable, where move returns a Point. | Lecture 4 - slide 13 : 29 Program 4 |
using System; public struct Point { private double x, y; public Point(double x, double y){ this.x = x; this.y = y; } public double Getx (){ return x; } public double Gety (){ return y; } public Point Move(double dx, double dy){ x += dx; y += dy; return this; // returns a copy of the current object } public override string ToString(){ return "Point: " + "(" + x + "," + y + ")" + "."; } } |