Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 1x 3x 3x 1x 1x 1x 1x 3x 3x 1x 4x | export interface Shape { area() : number } export class Square { constructor(private side: number) { } area() : number { return this.side * this.side } } export class Circle { constructor (public radius: number) {} area() : number { return Math.PI * this.radius * this.radius} } // represents ncopies of base shape, arranged in a row export class ShapeArray { constructor (public base: Shape, public ncopies: number) {} area() : number {return this.ncopies * this.base.area()} } export function area (s:Shape) : number { return s.area() } |