Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c07bfdd

Browse files
state update
1 parent d62b1a6 commit c07bfdd

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

‎design-pattern/factory/Main.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ public class Main {
88

99
public static void main(String[] args) {
1010

11-
Button bt1 = ButtonManager.build(ButtonManager.BUTTON_ANDROID);
12-
Button bt2 = ButtonManager.build(ButtonManager.BUTTON_IOS);
11+
Button button1 = ButtonManager.build(ButtonManager.BUTTON_ANDROID);
12+
Button button2 = ButtonManager.build(ButtonManager.BUTTON_IOS);
1313

14-
System.out.println(bt1);
15-
System.out.println(bt2);
14+
System.out.println(button1);
15+
System.out.println(button2);
1616

17-
bt1.onClick();
18-
bt2.onClick();
17+
button1.onClick();
18+
button2.onClick();
1919
}
2020
}

‎design-pattern/factory/abstracts/Main.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
*/
77
public class Main {
88
public static void main(String[] args) {
9-
Car alion = Toyota.getCar(Toyota.SEDAN);
10-
Car prado = Toyota.getCar(Toyota.SUV);
9+
Factory suvFactory = Toyota.factory(Toyota.SUV);
10+
Factory sedanFactory = Toyota.factory(Toyota.SEDAN);
11+
12+
Car alion = sedanFactory.build();
13+
Car prado = suvFactory.build();
1114

1215
System.out.println("Alion has "+alion.seat()+" seat");
1316
System.out.println("Prado has "+prado.seat()+" seat");

‎design-pattern/factory/abstracts/Toyota.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
public class Toyota {
88
public static final int SUV = 1;
99
public static final int SEDAN = 2;
10-
public static Car getCar(int type){
10+
11+
public static Factory factory(int type){
1112
switch(type){
12-
case SUV: return new SUVCar();
13-
case SEDAN: return new SedanCar();
13+
case SUV: return new SUVFactory();
14+
case SEDAN: return new SedanFactory();
1415
default: return null;
1516
}
1617
}

‎design-pattern/singleton/Main.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
public class Main {
88
public static void main(String[] args) {
9-
DateTime dt = DateTime.init();
10-
System.out.println(dt.now());
9+
DateTime clock = DateTime.init();
10+
System.out.println(clock.now());
1111
}
1212
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /