Skip to content

Instantly share code, notes, and snippets.

@chul-hyun
Last active September 18, 2018 08:20
Show Gist options
  • Save chul-hyun/455e5c6548cdffee140bfa258d7fdecc to your computer and use it in GitHub Desktop.
Save chul-hyun/455e5c6548cdffee140bfa258d7fdecc to your computer and use it in GitHub Desktop.
chapter 3
class Gear {
constructor(
readonly chainring: number,
readonly cog: number,
readonly rim: number,
readonly tire: number
) {}
get ratio() {
return this.chainring / this.cog;
}
get gearInches() {
return this.ratio * new Wheel(this.rim, this.tire).diameter;
}
}
class Wheel {
constructor(readonly rim: number, readonly tire: number) {}
get diameter() {
return this.rim * (this.tire * 2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment