Skip to content

Commit 2116191

Browse files
#28-javascript
1 parent 38992af commit 2116191

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* EJERCICIO:
3+
* Explora el "Principio SOLID de Sustitución de Liskov (Liskov Substitution Principle, LSP)"
4+
* y crea un ejemplo simple donde se muestre su funcionamiento
5+
* de forma correcta e incorrecta.
6+
*
7+
* DIFICULTAD EXTRA (opcional):
8+
* Crea una jerarquía de vehículos. Todos ellos deben poder acelerar y frenar, así como
9+
* cumplir el LSP.
10+
* Instrucciones:
11+
* 1. Crea la clase Vehículo.
12+
* 2. Añade tres subclases de Vehículo.
13+
* 3. Implementa las operaciones "acelerar" y "frenar" como corresponda.
14+
* 4. Desarrolla un código que compruebe que se cumple el LSP.
15+
*/
16+
17+
class Ball {
18+
throw() {
19+
console.log(`Throw the ball`);
20+
}
21+
}
22+
23+
class BowlingBall extends Ball {
24+
throw() {
25+
console.log(`Throw the ball toward pins`);
26+
}
27+
}
28+

0 commit comments

Comments
 (0)