Skip to content

Instantly share code, notes, and snippets.

@JLLeitschuh
Created March 9, 2018 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JLLeitschuh/cdfb6afa5159c96ef757b128b83f4dad to your computer and use it in GitHub Desktop.
Save JLLeitschuh/cdfb6afa5159c96ef757b128b83f4dad to your computer and use it in GitHub Desktop.
Immutable Vector using Information Expert Pattern
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