Created
November 18, 2019 23:44
-
-
Save whitelizard/f03b6515eedf5776a058b87c32c2820c to your computer and use it in GitHub Desktop.
Factory pattern tests
This file contains 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
const c1 = makeCircle([2.5, 0], 1.5); | |
const c2 = makeCircle([-2, 0], 2); | |
c1.area(); // -> 7.0685834705770345 | |
c2.area(); // -> 12.566370614359172 | |
c1.intersect(c2); // -> false | |
c1.getHits(); // -> 0 | |
c1.pos[0] = 1; | |
c1.intersect(c2); // -> true | |
c1.getHits(); // -> 1 | |
c2.getHits(); // -> 1 | |
c1.hits = 4; // OK, but this just creates a "dead" variable on the object, not used internally | |
c1.getHits(); // -> 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment