Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/geometry/Circle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export default class Circle extends Shape {
};
}

area() {
return Math.PI * this.radius * this.radius;
}

static fromAttributes(attributes: CircleAttributes): Circle {
const { radius } = attributes;
return new Circle(radius);
Expand Down
4 changes: 4 additions & 0 deletions src/geometry/Rectangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export default class Rectangle extends Shape {
return new Rectangle(width, height);
}

area() {
return this.width * this.height
}

get attributeData() {
return [
{
Expand Down
4 changes: 4 additions & 0 deletions src/geometry/Square.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export default class Square extends Rectangle {
);
}

area() {
return this.sideLength * this.sideLength;
}

getCloneAttributes() {
return [this.sideLength];
}
Expand Down