Skip to content

Commit cecdcea

Browse files
committed
Fixed Delegator
1 parent 4118dd0 commit cecdcea

File tree

8 files changed

+26
-16
lines changed

8 files changed

+26
-16
lines changed

src/CreationalPatterns/FactoryMethod_AbstractFactory/CarsFactory.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ public Vehicle getVehicle(String name){
88
return new Audi();
99
} else if (name.equals("Jeep")) {
1010
return new Jeep();
11-
} else if (name.equals("Toyota")) {
12-
return new Toyota();
1311
}
1412
return null;
1513
}

src/CreationalPatterns/FactoryMethod_AbstractFactory/Main.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package CreationalPatterns.FactoryMethod_AbstractFactory;
22

33
public class Main {
4+
private Car car;
45
public static void main(String[] args) {
56
AbstractFactory abstractFactory = new AbstractFactory();
67
Factory factory1 = abstractFactory.getFactory("Cars");

src/CreationalPatterns/FactoryMethod_AbstractFactory/Toyota.java

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/StructuralPatterns/Delegator/Child.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package StructuralPatterns.Delegator;
22

3-
public class Child {
3+
public class Child implements IDad, IMom {
44
private Dad dad;
55
private Mom mom;
66

7-
public Child(){
8-
this.dad = new Dad();
9-
this.mom = new Mom();
7+
public Child(String lastName){
8+
this.dad = new Dad(lastName);
9+
this.mom = new Mom(lastName);
1010
}
11+
@Override
1112
public String getLastName(){
1213
return dad.getLastName();
1314
}

src/StructuralPatterns/Delegator/Dad.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package StructuralPatterns.Delegator;
22

3-
public class Dad {
3+
public class Dad implements IDad {
44
private String lastName;
5+
public Dad(String lastName){
6+
this.lastName = lastName;
7+
}
8+
@Override
59
public String getLastName() {
610
return lastName;
711
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package StructuralPatterns.Delegator;
2+
3+
public interface IDad {
4+
String getLastName();
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package StructuralPatterns.Delegator;
2+
3+
public interface IMom {
4+
String getLastName();
5+
}

src/StructuralPatterns/Delegator/Mom.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package StructuralPatterns.Delegator;
22

3-
public class Mom {
3+
public class Mom implements IMom {
44
private String lastName;
5+
public Mom(String lastName){
6+
this.lastName = lastName;
7+
}
8+
@Override
59
public String getLastName() {
610
return lastName;
711
}

0 commit comments

Comments
 (0)