无法在我的 while 循环中调用这些方法

Trouble calling these methods in my while loop

我正在尝试使用以下方法为餐厅创建队列模拟:

QueueSim

    public static void queueSim(String filename) {
    System.out.println("=== queueSim ===");
    // Initialization
    ArrayList<String> dataAL = new ArrayList<>();
    ArrayList<Server> serverList = new ArrayList<Server>();

    String inputLine;

    // Read data from file into array list
    readDatafile(filename, dataAL);
    
    System.out.println(filename + " is used for this simulation.");
    System.out.println("Start simulation using filename -> " + filename);
    
    inputLine = dataAL.get(0); // first line of input data
    generatePrimarySecondaryServers(inputLine, serverList); //creates primary & secondary servers
    
    
    inputLine = dataAL.get(dataAL.size() - 1);
    int totalMinute = getTotalMinute(inputLine);
    
    System.out.println("\nTotal minute of simulation: " + totalMinute);
    
    int totalCustomers = dataAL.size() - 1;
    System.out.println("The total number of customers in this simulation is " + totalCustomers + ".");
    

    Queue pQueue = new Queue(dataAL.size() - 1); // creates primary queue
    Queue sQueue = new Queue(dataAL.size() - 1); // creates secondary queue
    
    
    int minute = 1;
    
     while (minute != totalMinute) {

        for (int loopCounter = 1; loopCounter < dataAL.size() - 1; loopCounter++) {
            
            inputLine = dataAL.get(loopCounter);
            int minuteArrive = getMinuteArrive(inputLine);
            int minuteForPServer = getMinuteForPrimaryServer(inputLine);
            int minuteForSServer = getMinuteForSecondaryServer(inputLine);
            
            Customer Customer = new Customer(minuteArrive, minuteForPServer, minuteForSServer);
        }
        
        processCustomer(Customer, pQueue, minuteArrive, minute);              
        processPServer(pQueue, serverList, minuteForPServer, minuteArrive, Customer);
        processPWork(serverList, sQueue, Customer);
        
        
        minute++;
        
    }
}

我在尝试让 while 循环工作时遇到了特别的问题。

         while (minute != totalMinute) {

        for (int loopCounter = 1; loopCounter < dataAL.size() - 1; loopCounter++) {
            
            inputLine = dataAL.get(loopCounter);
            int minuteArrive = getMinuteArrive(inputLine);
            int minuteForPServer = getMinuteForPrimaryServer(inputLine);
            int minuteForSServer = getMinuteForSecondaryServer(inputLine);
            
            Customer Customer = new Customer(minuteArrive, minuteForPServer, minuteForSServer);
        }
        
        processCustomer(Customer, pQueue, minuteArrive, minute);              
        processPServer(pQueue, serverList, minuteForPServer, minuteArrive, Customer);
        processPWork(serverList, sQueue, Customer);
        
        
        minute++;
        
    }

3 个方法,processCustomerprocessPServerprocessPWork 告诉我某些变量在争论无法解决。但是,如果我只是将这些方法放入嵌套的 for 循环中,我会在尝试编译时在 cmd 中得到以下输出,并且在不退出的情况下无法进行任何进一步的输入:

此外,我认为根据我的模拟要求,将这些方法放在 for 循环中没有多大意义。

如果我遗漏了任何重要的代码,我提前道歉,因为我对编程还很陌生。请让我知道,以便我可以编辑我的问题!感谢您的帮助!

这些变量是在 'for' 循环中定义的:

        int minuteArrive = getMinuteArrive(inputLine);
        int minuteForPServer = getMinuteForPrimaryServer(inputLine);
        int minuteForSServer = getMinuteForSecondaryServer(inputLine);

因此,它们只存在于for循环内部,无法在循环外部访问。这与方法调用无关,这是变量声明位置的结果。这个术语是 'scope',如果你想阅读它的话。

由于循环执行了很多次,因此您为这些变量分配了许多不同的值,所以我不清楚您希望在循环外对它们做什么。您想要哪个值?