public Simulator()
{
/** To do Auto-generated constructor stub4 */
dirs = new ArrayList<LinkedQueue<Vehicle>>();
for (int i = 0; i < 8; ++i)
dirs.add(new LinkedQueue<Vehicle>());
curTime = 0;
countVehicles = 0;
trafficLightsState = 0;
rnd = new Random();
}
/** Add some random vehicles to one of eight available directions and count number of vehicles to be added. */
void addRandomVehicles(int count)
{
for (int i = 0; i < count; ++i)
{
/** do not add if limit is reached */
if (countVehicles == MAX_NUM)
return;
/** choose random direction */
int wh = rnd.nextInt(8);
/** create vehicle on this direction */
Vehicle neww = new Vehicle(countVehicles + 1, curTime,
Vehicle.Street.values()[wh / 4], Vehicle.Directiron.values()[wh / 2]);
/* add to corresponding queue */
dirs.get(wh).push(neww);
countVehicles++;
}
}
我收到此错误:
Simulator.java:78: cannot find symbol
symbol : method add(Vehicle)
location: class java.util.ArrayList<jsjf.LinkedQueue<Vehicle>>
dirs.add(neww);
^
Simulator.java:105: cannot find symbol
symbol : method pop()
location: class jsjf.LinkedQueue<Vehicle>
Vehicle cur = dirs.get(j).pop();
^
2 errors
我在这里缺少什么想法?
答案 0 :(得分:1)
您已声明jsjf.LinkedQueue的ArrayList而非Vehicle的ArrayList。