Skip to content

Commit 764bf90

Browse files
authored
Merge pull request mouredev#7374 from danhingar/ejercicio29
#29 - Java
2 parents 7e5c020 + 221f283 commit 764bf90

File tree

1 file changed

+169
-0
lines changed

1 file changed

+169
-0
lines changed
+169
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
public class danhingar {
2+
3+
public static void main(String[] args) {
4+
Machine machine = new Machine();
5+
machine.eat();
6+
Human human = new Human();
7+
human.eat();
8+
9+
//CON ISP
10+
Machine1 machine1 = new Machine1();
11+
machine1.work();
12+
13+
Human1 human1 = new Human1();
14+
human1.eat();
15+
human1.work();
16+
17+
//Extra
18+
Printer printer1 = new Printer();
19+
printer1.print("doc.pdf");
20+
21+
ColorPrinter printer2 = new ColorPrinter();
22+
printer2.printColor("doc.pdf");
23+
24+
MultifunctionPrinter printer3 = new MultifunctionPrinter();
25+
printer3.print("doc.pdf");
26+
printer3.printColor("doc.pdf");
27+
printer3.scan("doc.pdf");
28+
printer3.sendFax("doc.pdf");
29+
}
30+
31+
}
32+
33+
// SIN ISP
34+
interface WorkerInteface {
35+
36+
void work();
37+
38+
void eat();
39+
}
40+
41+
class Human implements WorkerInteface {
42+
43+
@Override
44+
public void eat() {
45+
System.out.println("Comiendo");
46+
}
47+
48+
@Override
49+
public void work() {
50+
System.out.println("Trabajando");
51+
}
52+
53+
}
54+
55+
class Machine implements WorkerInteface {
56+
57+
@Override
58+
public void eat() {
59+
}
60+
61+
@Override
62+
public void work() {
63+
System.out.println("Trabajando");
64+
}
65+
66+
}
67+
68+
// CON ISP
69+
70+
interface WorkInterface {
71+
void work();
72+
73+
}
74+
75+
interface EatInterface {
76+
void eat();
77+
78+
}
79+
80+
81+
class Human1 implements WorkInterface,EatInterface {
82+
83+
@Override
84+
public void eat() {
85+
System.out.println("Comiendo");
86+
}
87+
88+
@Override
89+
public void work() {
90+
System.out.println("Trabajando");
91+
}
92+
93+
}
94+
95+
class Machine1 implements WorkInterface {
96+
97+
@Override
98+
public void work() {
99+
System.out.println("Trabajando");
100+
}
101+
102+
}
103+
104+
105+
//EXTRA
106+
interface PrinterInterface{
107+
void print(String document);
108+
}
109+
110+
interface PrinterColorInterface {
111+
void printColor(String document);
112+
}
113+
114+
interface ScannerInterface{
115+
void scan(String document);
116+
}
117+
118+
interface FaxInterface{
119+
void sendFax(String document);
120+
}
121+
122+
class Printer implements PrinterInterface{
123+
124+
@Override
125+
public void print(String document) {
126+
System.out.printf("Imprimiendo en blanco y negro el documento %s.\n",document);
127+
}
128+
129+
130+
}
131+
132+
class ColorPrinter implements PrinterColorInterface {
133+
134+
@Override
135+
public void printColor(String document) {
136+
System.out.printf("Imprimiendo a color el documento %s.\n",document);
137+
}
138+
139+
}
140+
141+
class MultifunctionPrinter implements PrinterInterface,PrinterColorInterface,ScannerInterface,FaxInterface {
142+
143+
@Override
144+
public void sendFax(String document) {
145+
System.out.printf("Enviado por fax el documento %s.\n",document);
146+
}
147+
148+
@Override
149+
public void scan(String document) {
150+
System.out.printf("Escaneando el documento %s.\n",document);
151+
System.out.printf("Documento %s escaneado.\n",document);
152+
}
153+
154+
@Override
155+
public void printColor(String document) {
156+
System.out.printf("Imprimiendo a color el documento %s.\n",document);
157+
}
158+
159+
@Override
160+
public void print(String document) {
161+
System.out.printf("Imprimiendo en blanco y negro el documento %s.\n",document);
162+
}
163+
164+
165+
}
166+
167+
168+
169+

0 commit comments

Comments
 (0)