ArrayStoreException失败

时间:2014-11-24 21:11:58

标签: java arrays bdd typed-arrays

我有一个问题:

我有这样的BDD表:

 And the following set of "Dishes"
    | Dish name      |calories| quality | cost |
    | grilled chicken|  400   |  high   |  12  |
    | lasagna        |  800   |  low    |   7  | 
    | gnocchi        |  700   |  high   |  12  |
    | pizza          |  400   |  low    |   7  |
    | snitzel        |  400   |  high   |   12 |
 And the following set of "Beverages"
    | Beverage name  | volume | quality | cost |
    | coke           |   35   |  high   |  5   |
    | fanta          |   35   |  low    |  2   | 
    | wine           |   50   |  high   |  5   |
    | beer           |   50   |  low    |  2   |
    | sprite         |   35   |  high   |  5   |

这是os BDD数据表的实现方法。

public void the_following_set_of(String type, DataTable list) throws Throwable 
{

    if (type.equals("Dishes"))
    {
        List<List<String>> dishes = list.raw();
        String[][] newdishes = new String[6][4];
        newdishes.equals(dishes.toArray(newdishes));

        for (int i = 1; i < 6; i++)
        {
            if (newdishes[i][2] == "high")
                kalite.equals(Quality.high);
            else
                kalite.equals(Quality.low);

            dishess.add(new Dish(newdishes[i][0], Integer.parseInt(newdishes[i][1]), kalite, Integer.parseInt(newdishes[i][3])));

        }
    }

    if (type.equals("Beverages"))
    {
        List<List<String>> beverages = list.raw();
        String[][] newbeverages = new String[6][4];
        newbeverages = beverages.toArray(newbeverages);


        for (int i = 1; i < 6; i++)
        {
            if (newbeverages[i][2] == "high")
                kalite.equals(Quality.high);
            else
                kalite.equals(Quality.low);

            beveragess.add(new Beverage(newbeverages[i][0], Integer.parseInt(newbeverages[i][1]), kalite, Integer.parseInt(newbeverages[i][3])));

        }
    }
    restaurant.createMenu(dishess, beveragess);
}

我无法从ArrayStoreException中幸存下来。通常我正在尝试做黄瓜功能测试,但是当我运行它时,我遇到了这个问题。

当我运行时,eclipse表示问题出现在这一行:

        newdishes.equals(dishes.toArray(newdishes));

我该如何解决?

感谢。

0 个答案:

没有答案