Skip to content

Instantly share code, notes, and snippets.

@chul-hyun
Last active September 18, 2018 09:47
Show Gist options
  • Save chul-hyun/55a666bfe83fa40413d88e3d7f66b78c to your computer and use it in GitHub Desktop.
Save chul-hyun/55a666bfe83fa40413d88e3d7f66b78c to your computer and use it in GitHub Desktop.
Chapter3
class Gear {
readonly wheel;
constructor(
readonly chainring: number,
readonly cog: number,
rim : number,
tire: number
) {
this.wheel = new Wheel(rim, tire);
}
get ratio() {
return this.chainring / this.cog;
}
get gearInches() {
return this.ratio * this.wheel.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