【发布时间】:2017-04-08 17:02:07
【问题描述】:
创建一个循环,直到乘客数组为空。在此循环中,您必须: 生成一个从 1 到 6 的随机数。将与您刚刚生成的人数相等的乘客数量添加到您在 Airport 类中的队列中。您需要从阵列中带走这些乘客。 我无法将数组中的元素添加到队列中。这是我尝试过的
void runningStimulation() throws FileNotFoundException, IOException {
String Line = "";
Scanner inFile1 = new Scanner(new BufferedReader(new FileReader("passengers.dat")));
List<String> temps = new ArrayList<String>();
while (inFile1.hasNext()) {
Line = inFile1.nextLine();
temps.add(Line);
}
inFile1.close();
String[] passengers = temps.toArray(new String[0]);
for (String s : passengers) {
System.out.println(s);
int Random = new Random().nextInt(6);
int k = Random;
addqueue(passengers(k));
【问题讨论】: