Skip to content

Feedback#1

Open
benspector-mls wants to merge 1 commit intoThe-Marcy-Lab-School:feedbackfrom
sjjames020:main
Open

Feedback#1
benspector-mls wants to merge 1 commit intoThe-Marcy-Lab-School:feedbackfrom
sjjames020:main

Conversation

@benspector-mls
Copy link
Contributor

No description provided.

Copy link
Contributor Author

@benspector-mls benspector-mls left a comment

Choose a reason for hiding this comment

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

@sjjames020

Score: 2 - You will need to resubmit this.

Good start on this! Your short responses are good and your code is mostly right. You just aren't invoking super() properly to make your child classes use their parent's constructor. Review how super() works and then resubmit once you've fixed the coding portion.

Comment on lines +16 to +20
super(side1, side2, side3, side4)
this.side1 = side1;
this.side2 = side2;
this.side3 = side1;
this.side4 = side2;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Take a closer look at the instructions, it says that Rectangles should be initialized with 2 arguments: a length and a width instead of the 4 arguments that you have here.

Also, remember that invoking super() will call the Rectangle's parent class constructor which already will assign the values side1 through side4 to this so you don't need to do that work here.

When you change the inputs to the Rectangle constructor to length and width, how can you invoke the super function in such a way that it can still provide the 4 sides needed by the Quadrilateral constructor?

Comment on lines +32 to +37
super(side1, side2, side3, side4)
this.sideSq = side1 * side1;
this.side1 = side1
this.side2 = side1
this.side3 = side1
this.side4 = side1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same feedback that I left for the Rectangle applies here.

Comment on lines +47 to +66
constructor(name, age, grade) {
this.name = name
this.age = age
this.grade = grade
this.friends = []
}
greet() {
return `Hello ${this.name}! `
}
getAge() {
return `${this.name}, You are ${this.age} years old.`
}
whatGrade() {
return `You are in ${this.grade}`
}

addFriend(...friendName) {
this.friends.push(friendName)

return `Adding ${friendName}...`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nicely done!


**1. What is inheritance in programming?**

**Inhertiance** is when a new class has all the functionality of the class in which it derived from while having its own functionality as well. The new class is called a *child* and the other class that it inherits from is refered to as the *parent* class.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent! (Except for some typos)

Suggested change
**Inhertiance** is when a new class has all the functionality of the class in which it derived from while having its own functionality as well. The new class is called a *child* and the other class that it inherits from is refered to as the *parent* class.
**Inheritance** is when a new class has all the functionality of the class which it is derived from while having its own functionality as well. The new class is called a *child* and the other class that it inherits from is referred to as the *parent* class.

}
}

//Car is this parent class, and BMW is the child class.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice example!

Comment on lines +34 to +35
Polymorphism is the idea that we can perform a task in multiple forms or ways and is applied of functions and methods.
Both the parent and child class have the `area()` method, but depending on which object the method is used on each time it is called it will output different things. `ob` is a new instance of `class B`, so when `area` is called on `ob` not only does it calculate `100 * 200` it also `console. logs` "Class B" and the reason it can calculate `100 * 200` is because of the `super class A`.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
Polymorphism is the idea that we can perform a task in multiple forms or ways and is applied of functions and methods.
Both the parent and child class have the `area()` method, but depending on which object the method is used on each time it is called it will output different things. `ob` is a new instance of `class B`, so when `area` is called on `ob` not only does it calculate `100 * 200` it also `console. logs` "Class B" and the reason it can calculate `100 * 200` is because of the `super class A`.
Polymorphism is the idea that we can perform a task in multiple forms or ways and is applied to functions and methods.
Both the parent and child class have the `area()` method, but depending on which object the method is used on each time it is called it will output different things. `ob` is a new instance of `class B`, so when `area` is called on `ob` not only does it calculate `100 * 200` it also `console. logs` "Class B" and the reason it can calculate `100 * 200` is because of the `super class A`.

This is a good example but it isn't the most creative. I don't even know what class A and B are meant to represent. Why do they have an area method? This isn't strictly a problem since the example demonstrates polymorphism but it doesn't make this a particularly engaging example either.

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