}
}
// File: rollable.jsl
// the interface representing a die
interface Rollable
{
public int sides();
public void load(RollStrategy r);
public int roll();
}
// File: rollstrategy.jsl
// the interface that represents a rolling strategy
interface RollStrategy
{
public int roll();
}
客户端文件(引用 dice.dll)。
app.jsl, cyclicroll.jsl
清单 6.
// File: app.jsl
public class App
{
public static int roll(Rollable d)
{
int i = d.roll();
return i;
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/