mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 00:58:24 +00:00
added proxy sample
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public class WizardTowerProxy extends WizardTower {
|
||||
|
||||
private static final int NUM_WIZARDS_ALLOWED = 3;
|
||||
|
||||
private int numWizards;
|
||||
|
||||
@Override
|
||||
public void enter(Wizard wizard) {
|
||||
if (numWizards < NUM_WIZARDS_ALLOWED) {
|
||||
super.enter(wizard);
|
||||
numWizards++;
|
||||
} else {
|
||||
System.out.println(wizard + " is not allowed to enter!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user