Created
November 21, 2014 19:39
-
-
Save anonymous/08e8d0d5d220543aa89b 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; | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment