Created
March 9, 2018 17:11
-
-
Save JLLeitschuh/cdfb6afa5159c96ef757b128b83f4dad to your computer and use it in GitHub Desktop.
Immutable Vector using Information Expert Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vector { | |
private final int x, y, z; | |
public Vector(int x, int y, int z) { | |
this.x = x; | |
this.y = y; | |
this.z = z; | |
} | |
public Vector crossProduct(Vector other) { | |
// Do your math here | |
// Return a NEW immutable Vector | |
return new Vector(newX, newY, newZ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment