Skip to content

Class inheritance #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
That's because the child constructor must call `super()`.
Eso es porque el constructor hijo debe llamar a `super()`.

Here's the corrected code:
Aqui el código corregido:

```js run
class Animal {
Expand All @@ -21,7 +21,7 @@ class Rabbit extends Animal {
}

*!*
let rabbit = new Rabbit("White Rabbit"); // ok now
let rabbit = new Rabbit("Conejo Blanco"); // ahora funciona
*/!*
alert(rabbit.name); // White Rabbit
alert(rabbit.name); // Conejo Blanco
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ importance: 5

---

# Error creating an instance
# Error al crear una instancia

Here's the code with `Rabbit` extending `Animal`.
Aquí está el código de la clase `Rabbit` que extiende a `Animal`.

Unfortunately, `Rabbit` objects can't be created. What's wrong? Fix it.
Desafortunadamente, los objetos `Rabbit` no se pueden crear. ¿Que pasa? Arréglalo.
```js run
class Animal {

Expand All @@ -24,7 +24,7 @@ class Rabbit extends Animal {
}

*!*
let rabbit = new Rabbit("White Rabbit"); // Error: this is not defined
let rabbit = new Rabbit("Conejo Blanco"); // Error: esto no está definido
*/!*
alert(rabbit.name);
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
clock.start();


/* Your class should work like this: */
/* Tu clase debería funcionar así: */

/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ importance: 5

---

# Extended clock
# Reloj extendido

We've got a `Clock` class. As of now, it prints the time every second.
Tenemos una clase de 'Clock'. A partir de ahora, imprime la hora cada segundo.


[js src="source.view/clock.js"]

Create a new class `ExtendedClock` that inherits from `Clock` and adds the parameter `precision` -- the number of `ms` between "ticks". Should be `1000` (1 second) by default.
Crea una nueva clase `ExtendedClock` que herede de `Clock` y agrega el parámetro `precision`: este es el número de `milisegundos` entre "tics". Debe ser `1000` (1 segundo) por defecto.

- Your code should be in the file `extended-clock.js`
- Don't modify the original `clock.js`. Extend it.
- Tu código debe estar en el archivo `extended-clock.js`
- No modifiques el `clock.js` original. Extiéndelo.

This file was deleted.

This file was deleted.

42 changes: 0 additions & 42 deletions 1-js/09-classes/02-class-inheritance/3-class-extend-object/task.md

This file was deleted.

Loading