最近遇到一个面向对象编程的问题,我想不出来。以下是说明:
1. create a banana object
2. all bananas are yellow
3. all bananas have a length and diameter which are set at instatiation
4. bananas also have isYummy property, which is set to true, because all bananas are yummy.
5. all bananas have the ability to rot, which toggles isYummy to false.
我真的不熟悉实例化长度和直径以及函数的含义。
这是我的方法。
const Banana = (color, length, diameter, isYummy) => {
this.color = 'yellow';
this.length = length;
this.diameter = diameter;
this.isYummy = true
}
let rot = new Banana('yellow', length, diameter, false)
PIPIONE
潇湘沐
DIEA
相关分类