You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* In object-oriented programming, the open–closed principle (OCP) states "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification"; that is, such an entity can allow its behaviour to be extended without modifying its source code.
21
+
/* In object-oriented programming, the open–closed principle (OCP) states "software entities (classes,
22
+
modules, functions, etc.) should be open for extension, but closed for modification"; that is, such
23
+
an entity can allow its behaviour to be extended without modifying its source code.
5
24
6
-
The name open–closed principle has been used in two ways. Both ways use generalizations (for instance, inheritance or delegate functions) to resolve the apparent dilemma, but the goals, techniques, and results are different. */
25
+
The name open–closed principle has been used in two ways. Both ways use generalizations (for instance,
26
+
inheritance or delegate functions) to resolve the apparent dilemma, but the goals, techniques, and
//#28 - Principio SOLID de Sustitución de Liskov (Liskov Substitution Principle, LSP)
2
+
/*
3
+
* EJERCICIO:
4
+
* Explora el "Principio SOLID de Sustitución de Liskov (Liskov Substitution Principle, LSP)"
5
+
* y crea un ejemplo simple donde se muestre su funcionamiento
6
+
* de forma correcta e incorrecta.
7
+
*
8
+
* DIFICULTAD EXTRA (opcional):
9
+
* Crea una jerarquía de vehículos. Todos ellos deben poder acelerar y frenar, así como
10
+
* cumplir el LSP.
11
+
* Instrucciones:
12
+
* 1. Crea la clase Vehículo.
13
+
* 2. Añade tres subclases de Vehículo.
14
+
* 3. Implementa las operaciones "acelerar" y "frenar" como corresponda.
15
+
* 4. Desarrolla un código que compruebe que se cumple el LSP.
16
+
*/
17
+
18
+
/* The Liskov Substitution Principle (LSP) is one of the five SOLID principles of object-oriented programming. This principle states that objects of a derived class should be able to replace objects of the base class without altering the correctness of the program. */
0 commit comments