X Tutup
Skip to content

Commit 4d08d16

Browse files
committed
iluwatar#107 JavaDoc for Proxy example
1 parent 0db6581 commit 4d08d16

File tree

4 files changed

+83
-73
lines changed

4 files changed

+83
-73
lines changed
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
package com.iluwatar.proxy;
2-
3-
/**
4-
*
5-
* Proxy (WizardTowerProxy) controls access to the actual object (WizardTower).
6-
*
7-
*/
8-
public class App {
9-
10-
public static void main(String[] args) {
11-
12-
WizardTowerProxy tower = new WizardTowerProxy();
13-
tower.enter(new Wizard("Red wizard"));
14-
tower.enter(new Wizard("White wizard"));
15-
tower.enter(new Wizard("Black wizard"));
16-
tower.enter(new Wizard("Green wizard"));
17-
tower.enter(new Wizard("Brown wizard"));
18-
19-
}
20-
}
1+
package com.iluwatar.proxy;
2+
3+
/**
4+
*
5+
* Proxy ({@link WizardTowerProxy}) controls access to the actual object ({@link WizardTower}).
6+
*
7+
*/
8+
public class App {
9+
10+
public static void main(String[] args) {
11+
12+
WizardTowerProxy tower = new WizardTowerProxy();
13+
tower.enter(new Wizard("Red wizard"));
14+
tower.enter(new Wizard("White wizard"));
15+
tower.enter(new Wizard("Black wizard"));
16+
tower.enter(new Wizard("Green wizard"));
17+
tower.enter(new Wizard("Brown wizard"));
18+
19+
}
20+
}
Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
package com.iluwatar.proxy;
2-
3-
public class Wizard {
4-
5-
private String name;
6-
7-
public Wizard(String name) {
8-
this.name = name;
9-
}
10-
11-
@Override
12-
public String toString() {
13-
return name;
14-
}
15-
16-
}
1+
package com.iluwatar.proxy;
2+
3+
/**
4+
*
5+
* Wizard
6+
*
7+
*/
8+
public class Wizard {
9+
10+
private String name;
11+
12+
public Wizard(String name) {
13+
this.name = name;
14+
}
15+
16+
@Override
17+
public String toString() {
18+
return name;
19+
}
20+
21+
}
Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
package com.iluwatar.proxy;
2-
3-
/**
4-
*
5-
* The proxy controlling access to WizardTower.
6-
*
7-
*/
8-
public class WizardTowerProxy extends WizardTower {
9-
10-
private static final int NUM_WIZARDS_ALLOWED = 3;
11-
12-
private int numWizards;
13-
14-
@Override
15-
public void enter(Wizard wizard) {
16-
if (numWizards < NUM_WIZARDS_ALLOWED) {
17-
super.enter(wizard);
18-
numWizards++;
19-
} else {
20-
System.out.println(wizard + " is not allowed to enter!");
21-
}
22-
}
23-
}
1+
package com.iluwatar.proxy;
2+
3+
/**
4+
*
5+
* The proxy controlling access to the {@link WizardTower}.
6+
*
7+
*/
8+
public class WizardTowerProxy extends WizardTower {
9+
10+
private static final int NUM_WIZARDS_ALLOWED = 3;
11+
12+
private int numWizards;
13+
14+
@Override
15+
public void enter(Wizard wizard) {
16+
if (numWizards < NUM_WIZARDS_ALLOWED) {
17+
super.enter(wizard);
18+
numWizards++;
19+
} else {
20+
System.out.println(wizard + " is not allowed to enter!");
21+
}
22+
}
23+
}
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
package com.iluwatar.proxy;
2-
3-
import org.junit.Test;
4-
5-
import com.iluwatar.proxy.App;
6-
7-
public class AppTest {
8-
9-
@Test
10-
public void test() {
11-
String[] args = {};
12-
App.main(args);
13-
}
14-
}
1+
package com.iluwatar.proxy;
2+
3+
import org.junit.Test;
4+
5+
import com.iluwatar.proxy.App;
6+
7+
/**
8+
*
9+
* Application test
10+
*
11+
*/
12+
public class AppTest {
13+
14+
@Test
15+
public void test() {
16+
String[] args = {};
17+
App.main(args);
18+
}
19+
}

0 commit comments

Comments
 (0)
X Tutup