JavaScript:
class Rectangle {
constructor(height, width) {
this.height = height;
this.width = width;
}
}Python:
class Rectangle:
def __init__(self, height, width):
self.height = height
self.width = widthJavaScript:
class Rectangle extends Shape {
constructor(height, width) {
super()
this.height = height;
this.width = width;
}
}Python:
class Rectangle(Shape):
def __init__(self, height, width):
super().__init__()
self.height = height
self.width = widthJavaScript:
class Rectangle extends Shape {
constructor(height, width) {
this.height = height;
this.width = width;
super.color
}
}Python:
class Rectangle(Shape):
def __init__(self, height, width):
self.height = height
self.width = width
super().colorJavaScript:
class Rectangle extends Shape {
constructor(height, width) {
this.height = height;
this.width = width;
this.color = super.getColor();
}
}Python:
class Rectangle(Shape):
def __init__(self, height, width):
self.height = height
self.width = width
self.color = super().getColor()JavaScript:
const Rectangle = class {
constructor(height, width) {
this.height = height;
this.width = width;
}
};Python:
class Rectangle:
def __init__(self, height, width):
self.height = height
self.width = widthJavaScript:
const Rectangle = class Rectangle2 {
constructor(height, width) {
this.height = height;
this.width = width;
}
};Python:
class Rectangle:
def __init__(self, height, width):
self.height = height
self.width = widthJavaScript:
class Rectangle {
constructor(height, width) {
this.height = height;
this.width = width;
}
format(text) {
return 'new text: ' + text + this.height;
}
printText(text) {
text = this.format(text)
console.log(text);
}
};Python:
class Rectangle:
def __init__(self, height, width):
self.height = height
self.width = width
def format(self, text):
return 'new text: ' + text + self.height
def printText(self, text):
text = self.format(text)
console.log(text)JavaScript:
class Rectangle {
static getName() {
return "Rectangle";
}
};Python:
class Rectangle:
@staticmethod
def getName():
return 'Rectangle'