24 lines
453 B
Java
Raw Normal View History

2014-08-16 20:28:07 +03:00
package com.iluwatar;
2014-08-31 10:23:14 +03:00
/**
*
* The proxy controlling access to WizardTower.
*
*/
2014-08-16 20:28:07 +03:00
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!");
}
}
}