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-10-08 13:42:12 +01:00
|
|
|
*
|
2014-08-31 10:23:14 +03:00
|
|
|
*/
|
2014-08-16 20:28:07 +03:00
|
|
|
public class WizardTowerProxy extends WizardTower {
|
|
|
|
|
|
|
|
private static final int NUM_WIZARDS_ALLOWED = 3;
|
2014-10-08 13:42:12 +01:00
|
|
|
|
2014-08-16 20:28:07 +03:00
|
|
|
private int numWizards;
|
2014-10-08 13:42:12 +01:00
|
|
|
|
2014-08-16 20:28:07 +03:00
|
|
|
@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!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|