-
-
Save ivanoats/0dfabc7660a04b83be94 to your computer and use it in GitHub Desktop.
Animal with Flow types
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
function Animal(name: string, speed: number, focus: number) { | |
this.name = name; | |
this.speed = speed || 1; | |
this.focus = focus || 1; | |
this.position = 0; | |
this.run = function() { | |
if (Math.random() * 10 < this.focus) { | |
this.position = this.position + this.speed; | |
} | |
}; | |
} |
Author
ivanoats
commented
Nov 21, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment