为什么我的导入文件不起作用?

时间:2011-09-27 10:20:02

标签: java import

我正在尝试使我的文件ClickingButtons.java工作,但我收到一个错误,它无法找到符号playerHasItem& freeSlots。现在我尝试导入我的ItemAssistant.java文件,该文件包含public ints playerHasItem& freeSlots,但保存和编译后仍然给我同样的错误! :(

这是我在ClickingButtons.java中的import语句:

import server.model.items.ItemAssistant;

这些是我的ItemAssistant的公开内容:

    public int freeSlots()
{
    int freeS = 0;
    for (int i=0; i < c.playerItems.length; i++){
        if (c.playerItems[i] <= 0){
            freeS++;
        }
    }
    return freeS;
}

    public boolean playerHasItem(int itemID, int amt, int slot) {
    itemID++;
    int found = 0;
    if (c.playerItems[slot] == (itemID)) {
        for (int i = 0; i < c.playerItems.length; i++)  {
            if (c.playerItems[i] == itemID)  {
                if(c.playerItemsN[i] >= amt) {
                    return true;
                } else {
                    found++;
                }
            }
        }
        if(found >= amt) {
            return true;
        }
        return false;
    }
    return false;
}
public boolean playerHasItem(int itemID, int amt) {
    itemID++;
    int found = 0;
    for (int i = 0; i < c.playerItems.length; i++) {
        if (c.playerItems[i] == itemID) {
            if(c.playerItemsN[i] >= amt){
                return true;
            } else{
                found++;
            }
        }
    }
        if(found >= amt) {
            return true;
        }
        return false;
}

调用这些内容的代码:

if (c.dialogueAction == 717) 
            {
                if (freeSlots() > 0)
                {
                    if (c.tempRune == 1)//air
                    {
                        if (c.omniQuest == 2)
                        {
                            if (c.getItems().playerHasItems(995,10000) && c.getItems().playerHasItems(556,10))
                                {
                                    c.getItems().deleteItems(995,10000);
                                    c.getItems().deleteItems(556,10);
                                    c.getItems().addItems(13599, 1);
                                    c.getDH().sendDialogues(749,57);
                                } else 
                                if (!c.getItems().playerHasItems(995,10000))
                                {
                                    c.getDH().sendDialogues(750, 57);
                                } else
                                if (!c.getItems().playerHasItems(556,10))
                                {
                                    c.getDH().sendDialogues(751, 57);
                                }
                        } else 
                        if (c.getItems().playerHasItems(995,20000) && c.getItems().playerHasItems(556,20))
                        {
                            c.getItems().deleteItems(995,20000);
                            c.getItems().deleteItems(556,20);
                            c.getItems().addItems(13599, 1);
                            c.getDH().sendDialogues(749,57);
                        } else
                        if (!c.getItems().playerHasItems(995,20000))
                        {
                            c.getDH().sendDialogues(750, 57);
                        } else
                        if (!c.getItems().playerHasItems(556,20))
                        {
                            c.getDH().sendDialogues(751, 57);
                        }
                    } else
                    if (c.tempRune == 6)//body
                    {
                        if (c.omniQuest == 2)
                        {
                            if (c.getItems().playerHasItems(995,10000) && c.getItems().playerHasItems(559,10))
                                {
                                    c.getItems().deleteItems(995,10000);
                                    c.getItems().deleteItems(559,10);
                                    c.getItems().addItems(13604, 1);
                                    c.getDH().sendDialogues(749,57);
                                } else 
                                if (!c.getItems().playerHasItems(995,10000))
                                {
                                    c.getDH().sendDialogues(750, 57);
                                } else
                                if (!c.getItems().playerHasItems(559,10))
                                {
                                    c.getDH().sendDialogues(751, 57);
                                }
                        } else 
                        if (c.getItems().playerHasItems(995,20000) && c.getItems().playerHasItems(559,20))
                        {
                            c.getItems().deleteItems(995,20000);
                            c.getItems().deleteItems(559,20);
                            c.getItems().addItems(13604, 1);
                            c.getDH().sendDialogues(749,57);
                        } else
                        if (!c.getItems().playerHasItems(995,20000))
                        {
                            c.getDH().sendDialogues(750, 57);
                        } else
                        if (!c.getItems().playerHasItems(559,20))
                        {
                            c.getDH().sendDialogues(751, 57);
                        }
                    } else
                    if (c.tempRune == 13)//astral 
                    {
                        if (c.omniQuest == 2)
                        {
                            if (c.getItems().playerHasItems(995,10000) && c.getItems().playerHasItems(9075,10))
                                {
                                    c.getItems().deleteItems(995,10000);
                                    c.getItems().deleteItems(9075,10);
                                    c.getItems().addItems(13611, 1);
                                    c.getDH().sendDialogues(749,57);
                                } else 
                                if (!c.getItems().playerHasItems(995,10000))
                                {
                                    c.getDH().sendDialogues(750, 57);
                                } else
                                if (!c.getItems().playerHasItems(9075,10))
                                {
                                    c.getDH().sendDialogues(751, 57);
                                }
                        } else 
                        if (c.getItems().playerHasItems(995,20000) && c.getItems().playerHasItems(9075,20))
                        {
                            c.getItems().deleteItems(995,20000);
                            c.getItems().deleteItems(9075,20);
                            c.getItems().addItems(13611, 1);
                            c.getDH().sendDialogues(749,57);
                        } else 
                        if (!c.getItems().playerHasItems(995,20000))
                        {
                            c.getDH().sendDialogues(750, 57);
                        } else
                        if (!c.getItems().playerHasItems(9075,20))
                        {
                            c.getDH().sendDialogues(751, 57);
                        }
                    }
                } else
                {
                    c.getDH().sendDialogues(752, 57);
                    c.tempRune = 0;
                }
            }

此外,导入目录是正确的。

为什么哦,为什么它不起作用?

1 个答案:

答案 0 :(得分:0)

您的声明描述了包含三个int参数的方法:

playerHasItem(int itemID, int amt, int slot)

然而你用两个来称呼它:

playerHasItems(995,20000)

没有声明两个参数的方法。