构造函数VDM ++中的错误

时间:2012-12-03 14:59:46

标签: compiler-errors vdm++

我在VDM ++ ToolBox Academic中遇到了一个愚蠢的错误。

当我尝试运行一个操作时,它给了我这个错误:

Run-Time Error 280: No constructor with this parameter list is in scope
value: "Game"

我的构造函数是:

public Game: Date * Team * Team ==> Game
Game(d,t1,t2) == (
    matchday := d;
    host := t1;
    visitor := t2;
    return self;
);

我在这里称呼它:

game := new Game(matchday1day1,groupA.teams(2),groupA.teams(3));

我有这个声明:

public groupA : Group;
public matchday1day1 : Date;

和(在小组中):

public teams : seq of Team;

错误指向Game的第一个字母。

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

如果我读到你对模型的描述正确,那么它应该是这样的:

class Group

instance variables
public teams : seq of Team := [new Team(),new Team(),new Team()];
end Group

class Team
end Team

class Date
end Date

class Game

instance variables
matchday: Date;
host : Team;
visitor : Team;

operations
public Game: Date * Team * Team ==> Game
Game(d,t1,t2) == (
    matchday := d;
    host := t1;
    visitor := t2;
    return self;
);
end Game

class Test
instance variables

public groupA : Group := new Group();
public matchday1day1 : Date := new Date();

operations

public test : ()==>()
test()== (
dcl game : Game;
 game := new Game(matchday1day1,groupA.teams(2),groupA.teams(3)) ;
)

end Test

我添加了Test并初始化了变量。

我在这里看不到任何错误,实际上它也在Overture中运行,这是VDM的另一个开源工具套件。我认为您的规范是正确的VDM。在Overture IDE中尝试一下。