我正在使用开源程序,但我不明白应该如何编写这个类。
间
public Room(float[][] points)
Creates a room from its name and the given coordinates.
我猜这有点像
Room Parallelogram_Room = new Room{{0f,0f},{0f,400f},{625f,400f},{625f,400f},{625f,0f},{0f,0f}};
但它会出错,或者
Room Parallelogram_Room = new Room([0f][0f]);
但仍然出错。
拜托,我被卡住了!
答案 0 :(得分:4)
你弄乱了语法。用括号包裹数组。
为了更清楚,创建数组然后将其传递给构造函数。
float[][] points = {{0f,0f},{0f,400f},{625f,400f},{625f,400f},{625f,0f},{0f,0f}};
Room Parallelogram_Room = new Room(points);
答案 1 :(得分:4)
使用Room room = new Room(new float[][] { {3, 4}, {4, 5}, {4, 6} });