1

在我的 AS 级计算课程中,我们使用的是 Turbo Pascal,而对于扩展工作,我的任务是制作 Blackjack/21 风格的纸牌游戏。我决定为通用纸牌游戏数据结构制作一个单元:

unit CardLib;

interface

type
    CardSuite = (clubs, diamonds, hearts, spades);

    Card = record
        name:String;
        value:Integer;
        suite:CardSuite;
    end;

    CardDeck = object
        cards: Array[0..51] of Card;
        freeIndex: Integer;
        constructor init;
        procedure addNewCard(suite:CardSuite, name:String, value:Integer);
        procedure addCard(c:Card);
        function drawCard:Card;
        destructor done;
    end;

    CardHand = object
        cards: Array[0..51] of Card;
        freeIndex: Integer;
        constructor init(deck:CardDeck, size:Integer);
        function getLowestTotal:Integer; {Aces are worth 1}
        function getHighestTotal:Integer; {Aces are worth 11}
        procedure addCard(c:Card);
        destructor done;
    end;
...

我在 Turbo Pascal 兼容模式下使用 Free Pascal 编译此代码,但出现以下错误:

CardLib.pas(18,39) Fatal: Syntax error, ")" expected but "," found
Fatal: Compilation aborted
Error: /usr/bin/ppcarm returned an error exitcode (normal if you did not specify a source file to be compiled)

如果我注释掉 addNewCard 过程,我会在 CardHand 构造函数中得到相同的错误。任何想法是什么原因造成的?

4

1 回答 1

3

使用分号分隔参数。

procedure addNewCard(suite:CardSuite; name:String; value:Integer);
于 2012-11-14T18:01:34.953 回答