Khan academy, diseño orientado a objetos, floricultor. parte 5 ¡Muy bien! Tu prototipo de Tulipahora está basado en el prototipo Flower. Ahora llama al constructor Flower desde tu constructor Tulip. que tengo que hacer este es mi codigo /************* *OBJECT TYPES **************/ /****************** *Flower Object Type *******************/ var Flower = function (x, y, height) { this.x = x; this.y = y; this.height = height; }; Flower.prototype.growBy = function(amount){ this.height += amount; }; /***************** *Tulip Object Type ******************/ var Tulip = function(x, y, height) { this.x = x; this.y = y; this.height = height; }; Tulip.prototype = Object.create(Flower.prototype); Tulip.prototype.draw = function() { noStroke(); fill(16, 122, 12); rect(this.x, this.y, 10, -this.height); fill(255, 0, 0); // petals ellipse(this.x+5, this.y-this.height, 44, 44); triangle(this.x-16, this.y-this.height, this.x+20, this.y-this.height, this.x-20, this.y-this.height-31); triangle(this.x-14, this.y-this.height, this.x+24, this.y-this.height, this.x+3, this.y-this.height-39); triangle(this.x-4, this.y-this.height, this.x+26, this.y-this.height, this.x+29, this.y-this.height-36); }; Tulip.prototype.growBy = function(amount) { this.height += amount; }; /********************* *Sunflower Object Type **********************/ var Sunflower = function(x, y, height) { this.x = x; this.y = y; this.height = height; }; Sunflower.prototype = Object.create(Flower.prototype); Sunflower.prototype.draw = function() { fill(16, 122, 12); rect(this.x, this.y, 10, -this.height); // petals stroke(0, 0, 0); fill(255, 221, 0); ellipse(this.x-10, this.y-this.height, 20, 18); ellipse(this.x+5, this.y-this.height-15, 20, 18); ellipse(this.x+5, this.y-this.height+15, 20, 18); ellipse(this.x+20, this.y-this.height, 20, 18); fill(20, 20, 20); ellipse(this.x+5, this.y-this.height, 20, 20); }; Sunflower.prototype.growBy = function(amount) { this.height += amount; }; /************** *MAIN PROGRAM ***************/ /** create object instances **/ var tulip = new Tulip(38, 390, 150); var sunflower = new Sunflower(186, 390, 100); var rosa = new Tulip(289, 390, 150); var girasol = new Sunflower(308,390,100); var drawScene = function() { background(207, 250, 255); tulip.draw(); sunflower.draw(); rosa.draw(); girasol.draw(); }; mouseClicked = function() { tulip.growBy(10); sunflower.growBy(20); rosa.growBy(10); girasol.growBy(20); drawScene(); }; drawScene();

Respuestas

Respuesta dada por: heuyenin13
1

ala :v sólo quiero puntos y ya bye

Respuesta dada por: Eduardo28082008
1

Respuesta:

Que es eso?

Explicación:

Si te sirve pon me corona.  :)

Preguntas similares