public interface PlanetaryDeathRay { public void aim(double xPosition, double yPosition); public boolean fire(); /* call this if she says the rebel base is on Dantooine */}public class BlueLaserPlanetaryDeathRay implements PlanetaryDeathRay { /* implementation here */ }public class GreenLaserPlanetaryDeathRay implements PlanetaryDeathRay { /* implementation here */ }
public abstract class PlanetaryDeathRayTestCase extends TestCase { protected PlanetaryDeathRay deathRay; @Override protected void setUp() { deathRay = createDeathRay(); } @Override protected void tearDown() { deathRay = null; } protected abstract PlanetaryDeathRay createDeathRay(); /* create the PlanetaryDeathRay to test */ public void testAim() { /* write implementation-independent tests here against deathRay.aim() */ } public void testFire() { /* write implementation-independent tests here against deathRay.fire() */ }}
public class BlueLaserPlanetaryDeathRayTest extends PlanetaryDeathRayTestCase { protected PlanetaryDeathRay createDeathRay() { return new BlueLaserPlanetaryDeathRay(); }}
No comments :
Post a Comment