Skip to content

number 46#10

Open
17kikak wants to merge 1 commit intomasterfrom
number-46
Open

number 46#10
17kikak wants to merge 1 commit intomasterfrom
number-46

Conversation

@17kikak
Copy link
Owner

@17kikak 17kikak commented Oct 22, 2017

completed

@griselleong
@rickyc

completed
}

class Rectangle extends Shape {
constructor(length, width) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this constructor is exactly identical as Shape's constructor, it is not necessary. It will automatically take everything inside the Shape class.


class Triangle extends Shape {
constructor(length, width) {
super(length, width / 2);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 , is it necessary to divide the width by 2? If I gave you this triangle and told you the width was 10cm and the height was 6cm. Would you expect the width to be 5?

}
class Circle extends Shape {
constructor(radius) {
super(radius * radius, Math.PI);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually an interesting one! Since a circle doesn't really have a length or height, but what you did is clever since it would still leverage the area function 👍. One thing to note is that it's not always necessary to call super.

}
class Cube extends Shape {
constructor(length, width, height) {
super(length * width, height);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one might actually be better as something like this. You would also need to override the area function meaning you need to create a new one in this class.

constructor(length, width, height) {
  this.height = height;
  super(length, width);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants