File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Roadmap/28 - SOLID LSP/javascript Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 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+
You can’t perform that action at this time.
0 commit comments