Skip to content

Commit 2b17f6f

Browse files
committed
ejemplo con isp
1 parent 68c59df commit 2b17f6f

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

Roadmap/28 - SOLID LSP/java/.LCKsimonguzman.java~

-1
This file was deleted.

Roadmap/29 - SOLID ISP/java/simonguzman.java

+35
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,49 @@
11
public class simonguzman {
22
public static void main(String[] args) {
33
exampleNoIsp();
4+
exampleIsp();
45
}
56

67
/******************************** Ejercicio adicional con isp ********************************/
78

89
/******************************** Ejercicio adicional sin isp ********************************/
910

1011
/******************************** Ejemplo con isp ********************************/
12+
static void exampleIsp(){
13+
Workable robotIsp = new RobotIsp();
14+
robotIsp.work();
1115

16+
Employee employee = new Employee();
17+
employee.work();
18+
employee.eat();
19+
}
20+
21+
static interface Workable {
22+
void work();
23+
}
24+
25+
static interface Eatable {
26+
void eat();
27+
}
28+
29+
static class RobotIsp implements Workable {
30+
@Override
31+
public void work() {
32+
System.out.println("El robot está trabajando.");
33+
}
34+
}
35+
36+
static class Employee implements Workable, Eatable {
37+
@Override
38+
public void work() {
39+
System.out.println("El empleado está trabajando.");
40+
}
41+
42+
@Override
43+
public void eat() {
44+
System.out.println("El empleado está comiendo.");
45+
}
46+
}
1247
/******************************** Ejemplo sin isp ********************************/
1348
static void exampleNoIsp(){
1449
Worker robot = new Robot();

0 commit comments

Comments
 (0)