Ward Bell 4253378e66 docs(hierarchical-di): Correct avoidance example (#3086) and more (#3091)
* closes #3086
* samples reworked to conform to our sample style, make more sense, and cover the points in prose.
* copy edits to bring closer to Google docs standards.
2017-01-13 13:21:22 -08:00

32 lines
578 B
TypeScript

// #docregion
export class Hero {
id: number;
name: string;
tid: string; // tax id
}
//// HeroTaxReturn ////
let nextId = 100;
export class HeroTaxReturn {
constructor(
public id = nextId++,
public hero: Hero,
public income = 0 ) {
if (id === 0) { id = nextId++; }
}
get name() { return this.hero.name; }
get tax() { return this.income ? .10 * this.income : 0; }
get tid() { return this.hero.tid; }
toString() {
return `${this.hero.name}`;
}
clone() {
return new HeroTaxReturn(this.id, this.hero, this.income);
}
}