File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Roadmap/27 - SOLID OCP/java Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,19 @@ public static void main(String[] args) {
77 //libraryViolationOcp();
88 libraryFollowOCP ();
99 }
10+ /*************************** Ejercicio adicional sin ocp(Incorrecto) ***************************/
11+ static class Calculator {
12+ public double calculate (String operation , double num1 , double num2 ){
13+ switch (operation ) {
14+ case "sum" : return num1 + num2 ;
15+ case "substract" : return num1 - num2 ;
16+ case "multiply" : return num1 * num2 ;
17+ case "divide" : return num1 / num2 ;
18+ default :
19+ throw new UnsupportedOperationException ("Operacion no soportada" );
20+ }
21+ }
22+ }
1023
1124 /*************************** Ejemplo con ocp(Correcto) ***************************/
1225 static void libraryFollowOCP (){
You can’t perform that action at this time.
0 commit comments