Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. namespace ReadOnlyVectorTask
  2. {
  3. public class ReadOnlyVector
  4. {
  5. public readonly double X;
  6. public readonly double Y;
  7.  
  8. public ReadOnlyVector(double x, double y)
  9. {
  10. X = x;
  11. Y = y;
  12. }
  13.  
  14. public ReadOnlyVector Add(ReadOnlyVector newVector)
  15. {
  16. return new ReadOnlyVector(X + newVector.X, Y + newVector.Y);
  17. }
  18.  
  19. public ReadOnlyVector WithX(double x)
  20. {
  21. return new ReadOnlyVector(x, Y);
  22. }
  23.  
  24. public ReadOnlyVector WithY(double y)
  25. {
  26. return new ReadOnlyVector(X, y);
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement